python - Django-registration 1.0 注册不起作用

标签 python django registration

我正在尝试使用 django-registration 1.0,但是当我点击注册按钮时我被卡住了。这就是我得到的。

TypeError at /accounts/register/
Unicode-objects must be encoded before hashing
Request Method: POST
Request URL:    http://127.0.0.1:8000/accounts/register/
Django Version: 1.5.1
Exception Type: TypeError
Exception Value:    
Unicode-objects must be encoded before hashing
Exception Location: C:\Python33\lib\site-packages\registration\models.py in  

追溯复制粘贴模式

Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/accounts/register/

Django Version: 1.5.1
Python Version: 3.3.2
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.contenttypes',
'django.contrib.admin',
'MyDjangoApp',
'Books',
'registration',
'django.core.mail',
'user_profile')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')


 Traceback:
 File "C:\Python33\lib\site-packages\django\core\handlers\base.py" in get_response
 115.                         response = callback(request, *callback_args,  

 **callback_kwargs)
 File "C:\Python33\lib\site-packages\django\views\generic\base.py" in view
 68.             return self.dispatch(request, *args, **kwargs)
 File "C:\Python33\lib\site-packages\registration\views.py" in dispatch
  79.         return super(RegistrationView, self).dispatch(request, *args, **kwargs)
 File "C:\Python33\lib\site-packages\django\views\generic\base.py" in dispatch
  86.         return handler(request, *args, **kwargs)
File "C:\Python33\lib\site-packages\registration\views.py" in post
  35.             return self.form_valid(request, form)
File "C:\Python33\lib\site-packages\registration\views.py" in form_valid
 82.         new_user = self.register(request, **form.cleaned_data)
File "C:\Python33\lib\site-packages\registration\backends\default\views.py" in register
 80.                                                                     password,         site)
File "C:\Python33\lib\site-packages\django\db\transaction.py" in inner
 223.                 return func(*args, **kwargs)
File "C:\Python33\lib\site-packages\registration\models.py" in create_inactive_user
  88.         registration_profile = self.create_profile(new_user)
File "C:\Python33\lib\site-packages\registration\models.py" in create_profile
  106.         salt = hashlib.sha1(str(random.random())).hexdigest()[:5]

Exception Type: TypeError at /accounts/register/
Exception Value: Unicode-objects must be encoded before hashing

有什么可能出错的建议吗?除了安装应用程序以及对 url 和设置文件进行一些细微更改之外,我没有做任何其他事情。

最佳答案

问题是你使用的是Python 3;并且 django-registration 尚不兼容。您需要使用Python 2.7.x

关于python - Django-registration 1.0 注册不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20087128/

相关文章:

python - 如何根据列索引列表从pyspark中的csv文件中选择某些列,然后确定它们的不同长度

python - 在Python中如何检查两个变量的相加是否是同一类型?

javascript - 如何仅在用户输入内容时验证注册

php - 阻止一个人创建多个帐户的最佳方法

python - 如何使用层次聚类将聚类分配给新的观察结果(测试数据)?

python - 为什么python中的字符串拼接顺序对速度影响很大?

Django 对象创建和 Postgres 序列

python mysqldb 问题与 python 2.6 & 或 mysql 接口(interface)

python - 如何从 Django 内置 API 文档中排除 rest-auth 端点?

django - 配置 django-userena