我正在尝试使用 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/