我试图将django-allauth添加到我的Django Web应用程序中,尝试注册时出现错误。 发送电子邮件时发生错误。 此时的域变量将获取具有非ASCII字符的计算机名称(我在locahost中工作)。 该错误在Django的core.mail模块中提出。 我该如何解决?

提前致谢。

Environment:


Request Method: POST
Request URL: http://localhost:8000/accounts/signup/

Django Version: 1.8.1
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django_extensions',
 'debug_toolbar',
 'sorl.thumbnail',
 'core',
 'authentication',
 'allauth',
 'allauth.account',
 'allauth.socialaccount')
Installed Middleware:
(u'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/views/generic/base.py" in view
  71.             return self.dispatch(request, *args, **kwargs)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  34.             return bound_func(*args, **kwargs)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  76.             return view(request, *args, **kwargs)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  30.                 return func.__get__(self, type(self))(*args2, **kwargs2)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/views.py" in dispatch
  169.         return super(SignupView, self).dispatch(request, *args, **kwargs)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/views.py" in dispatch
  66.                                             **kwargs)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/views.py" in dispatch
  147.                                                           **kwargs)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
  89.         return handler(request, *args, **kwargs)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/views.py" in post
  82.             response = self.form_valid(form)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/views.py" in form_valid
  185.                                self.get_success_url())
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/utils.py" in complete_signup
  157.                          signal_kwargs=signal_kwargs)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/utils.py" in perform_login
  114.             send_email_confirmation(request, user, signup=signup)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/utils.py" in send_email_confirmation
  286.                                                     signup=signup)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/models.py" in send_confirmation
  60.         confirmation.send(request, signup=signup)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/models.py" in send
  137.                                 ctx)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/allauth/account/adapter.py" in send_mail
  101.         msg.send()
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/core/mail/message.py" in send
  304.         return self.get_connection(fail_silently).send_messages([self])
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/core/mail/backends/console.py" in send_messages
  36.                     self.write_message(message)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/core/mail/backends/console.py" in write_message
  18.         msg = message.message()
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/core/mail/message.py" in message
  284.             msg['Message-ID'] = make_msgid(domain=DNS_NAME)
File "/Users/user/.virtualenvs/app/lib/python2.7/site-packages/django/core/mail/message.py" in make_msgid
  64.     msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, domain)

Exception Type: UnicodeDecodeError at /accounts/signup/
Exception Value: 'ascii' codec can't decode byte 0xc3 in position 18: ordinal not in range(128)

===============>>#1 票数:0

我回答我自己的问题。 这是python的现有问题( 问题9377 )。 基本上,有必要将计算机的名称更改为不包含非ASCII字符的名称。 我的建议是使用以下命令通过终端执行此操作:sudo scutil --set HostName [NewHostNameHere]。 可能还需要重新启动计算机。

  ask by pypy translate from so

未解决问题?本站智能推荐: