ConnectionRefusedError in dJango rest api while registration process
注册用户时显示ConnectionReutedError错误,
在数据库中添加了基本信息,但密码字段为空,提交的其他数据库字段请查找以下错误和我们的类代码。
等级
类ProfessionalRegistrationSerializer(序列化程序.HyperlinkedModelSerializer):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | password = serializers.CharField(max_length=20, write_only=True) email = serializers.EmailField() first_name = serializers.CharField(max_length=30) last_name = serializers.CharField(max_length=30) class Meta: model = User fields = ('url', 'id', 'first_name', 'last_name', 'email', 'password') def validate_email(self, value): from validate_email_address import validate_email if User.all_objects.filter(email=value.lower()).exists(): raise serializers.ValidationError('User with this email already exists.') return value.lower() def create(self, validated_data): password = validated_data.pop('password') email = validated_data.pop('email') user = User.objects.create( username=email.lower(), email=email.lower(), role_id=1, **validated_data) user.set_password(password) user.save() return user |
误差
/api/v1/register/professional处的connectionrefusedError/[errno 111]连接被拒绝请求方式:post请求URL:http://127.0.0.1:8000/api/v1/register/professional/Django版本:1.8.14异常类型:ConnectionReutedError异常值:[errno 111]连接被拒绝异常位置:create_connection第702行中的/usr/lib/python3.5/socket.pypython可执行文件:/home/project_backend/env/bin/pythonpython版本:3.5.2python路径:['/home/project_backend','/home/project_backend/env/lib/python35.zip','/home/project_backend/env/lib/python3.5','/home/project_backend/env/lib/python3.5/plat-x86_64-linux-gnu','/home/project_backend/env/lib/python3.5/lib dynload','/usr/lib/python3.5','/usr/lib/python3.5/plat-x86_64-linux-gnu','/home/project_backend/env/lib/python3.5/site包','/home/project_backend/env/lib/python3.5/site packages/setuptools-36.0.1-py3.5.egg']
回溯
1 | File"/home/project_backend/env/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response |
号
132.response=wrapped_callback(request,*callback_args,**callback_kwargs)file"/home/project_backend/env/lib/python3.5/site packages/django/views/decorators/csrf.py"in wrapped_view58岁。返回视图_Func(*args,**kwargs)视图中的文件"/home/project_backend/env/lib/python3.5/site packages/django/views/generic/base.py"71.返回self.dispatch(请求,*args,*kwargs)调度中的文件"/home/project_backend/env/lib/python3.5/site packages/rest_framework/views.py"464年。响应=self.handle_异常(exc)调度中的文件"/home/project_backend/env/lib/python3.5/site packages/rest_framework/views.py"461页。响应=处理程序(请求、*args、*kwargs)发布文件"/home/project_backend/filmop/apps/registrations/views.py"53岁。user=serializer.save(工作状态=用户类型)save中的文件"/home/project_backend/env/lib/python3.5/site packages/rest_framework/serializer.py"175岁。self.instance=self.create(已验证的数据)创建中的文件"/home/project_backend/project/apps/registrations/serializer.py"157页。**已验证的数据)manager_方法中的文件"/home/project_backend/env/lib/python3.5/site packages/django/db/models/manager.py"127页。返回getattr(self.get_queryset(),name)(*args,**kwargs)创建中的文件"/home/project_backend/env/lib/python3.5/site packages/django/db/models/query.py"348年。obj.save(强制插入=真,使用=self.db)保存中的文件"/home/project_backend/project/libs/accounts/models.py"217.super()。保存(*args,**kwargs)保存中的文件"/home/project_backend/env/lib/python3.5/site packages/django/db/models/base.py"734年。force_update=force_update,update_fields=更新_fields)save_base中的file"/home/project_backend/env/lib/python3.5/site packages/django/db/models/base.py"771年。update_fields=更新_fields,raw=原始,using=使用)send中的文件"/home/project_backend/env/lib/python3.5/site packages/django/dispatch/dispatcher.py"189年。响应=接收器(信号=自身,发送方=发送方,**已命名)创建用户设置中的文件"/home/project_backend/filmoup/libs/accounts/signals.py"19.创建用户(实例)在Create_ejabberd_用户中的文件"/home/project_backend/project/libs/accounts/signals.py"11.创建(username=str(user.id),password=str(token.key))创建中的文件"/home/project_backend/project/libs/accounts/models.py"73岁。ctl.register(user=kwargs['username'],password=kwargs['password'])寄存器中的文件"/home/project_backend/project/libs/ejabberdctl.py"54英寸密码:密码)ctl中的文件"/home/project_backend/project/libs/ejaberdctl.py"32岁。返回fn(self.params,有效载荷)调用中的文件"/usr/lib/python3.5/xmlrpc/client.py"1092年。返回self。uu send(self.u name,args)请求中的文件"/usr/lib/python3.5/xmlrpc/client.py"1432年。verbose=self.u verbose请求中的文件"/usr/lib/python3.5/xmlrpc/client.py"1134年。返回self.single请求(主机、处理程序、请求主体、详细)单个请求中的文件"/usr/lib/python3.5/xmlrpc/client.py"1146年。http_conn=self.send_请求(主机、处理程序、请求主体、详细)发送请求中的文件"/usr/lib/python3.5/xmlrpc/client.py"1259年。self.发送内容(连接,请求主体)发送目录中的文件"/usr/lib/python3.5/xmlrpc/client.py"1289年。connection.endheaders(请求主体)文件"/usr/lib/python3.5/http/client.py"在endheaders中1102年。Self.u发送输出(消息正文)文件/usr/lib/python3
您对无法访问/未配置/未运行的远程服务器执行调用。
这不是Django或DRF的问题。
我收到同样的错误,可能是由于电子邮件验证。我在setting.py文件中添加了以下代码,现在身份验证工作正常
1 2 3 4 5 | ACCOUNT_EMAIL_VERIFICATION = 'none' ACCOUNT_AUTHENTICATION_METHOD = 'username' ACCOUNT_EMAIL_REQUIRED = False |