我使用jquery将请求发布到网址(/sendOrder/
):
params = {
"username": $("#username").val(),
"tel":$("#tel").val(),
"email":$("#email").val(),
"address":$("#address").val(),
"content":$("#content").val()
};
$.post("/sendOrder/",params,function(result){
alert(result);
});
但是当我要求时,我收到一个错误:
无法加载资源:服务器响应状态为500(内部服务器错误)
详情请注明:
/ sendOrder /
中
的UnicodeEncodeError ' ASCII'编解码器不能对位置0-3中的字符进行编码:序数不在范围(128)
urls.py
:
urlpatterns = [
...
url(r'^sendOrder/', f_end_v.sendOrder)
]
在views.py
:
def sendOrder(request):
if request.method == 'POST':
pass
我已在# -*- coding: utf-8 -*-
中检查了views.py
。
有些朋友知道我为什么会收到这个错误?
修改-1
所有追溯:
UnicodeEncodeError at /sendOrder/
'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
Request Method: POST
Request URL: http://localhost:8000/sendOrder/
Django Version: 1.11.2
Python Executable: /usr/bin/python
Python Version: 2.7.10
Python Path: ['/Users/luowensheng/Desktop/TestIOS/TestPython/gjjWeb', '/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg', '/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']
Server time: Mon, 28 Aug 2017 08:16:31 +0000
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'frontend']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/luowensheng/Desktop/TestIOS/TestPython/gjjWeb/frontend/views.py" in sendOrder
204. msg = MIMEText(email_content)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/mime/text.py" in __init__
30. self.set_payload(_text, _charset)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py" in set_payload
226. self.set_charset(charset)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py" in set_charset
262. self._payload = self._payload.encode(charset.output_charset)
Exception Type: UnicodeEncodeError at /sendOrder/
Exception Value: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
Request information:
USER: AnonymousUser
GET: No GET data
POST:
username = u'daesfrgdf'
content = u'wqerteasdasd'
tel = u'12345678900'
email = u'qwertyu'
address = u'asdasdqewrt'
FILES: No FILES data
COOKIES:
csrftoken = 'hDfn64C4IH4iZHujemSrED3PT4AFGeVyEiwpJ9B5ZXFBxDCuZRA0L9QiT82OGAeZ'
META:
Apple_PubSub_Socket_Render = '/private/tmp/com.apple.launchd.JPvZRl4jtE/Render'
BASH_FUNC_generate_command_executed_sequence%% = "() { printf '\\e\\7'\n}"
CONTENT_LENGTH = '89'
CONTENT_TYPE = 'application/x-www-form-urlencoded; charset=UTF-8'
DJANGO_SETTINGS_MODULE = 'gjjWeb.settings'
GATEWAY_INTERFACE = 'CGI/1.1'
GEM_HOME = '/Users/luowensheng/.rvm/gems/ruby-2.3.3'
GEM_PATH = '/Users/luowensheng/.rvm/gems/ruby-2.3.3:/Users/luowensheng/.rvm/gems/ruby-2.3.3@global'
GOBIN = '/usr/local/Cellar/go/1.7.6/bin'
GOPATH = '/usr/local/Cellar/go/1.7.6'
HOME = '/Users/luowensheng'
HTTP_ACCEPT = '*/*'
HTTP_ACCEPT_ENCODING = 'gzip, deflate'
HTTP_ACCEPT_LANGUAGE = 'zh-cn'
HTTP_CONNECTION = 'keep-alive'
HTTP_COOKIE = 'csrftoken=hDfn64C4IH4iZHujemSrED3PT4AFGeVyEiwpJ9B5ZXFBxDCuZRA0L9QiT82OGAeZ'
HTTP_HOST = 'localhost:8000'
HTTP_ORIGIN = 'http://localhost:8000'
HTTP_REFERER = 'http://localhost:8000/message/'
HTTP_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8'
HTTP_X_REQUESTED_WITH = 'XMLHttpRequest'
IRBRC = '/Users/luowensheng/.rvm/rubies/ruby-2.3.3/.irbrc'
LC_CTYPE = 'zh_CN.UTF-8'
LOGNAME = 'ldl'
MY_RUBY_HOME = '/Users/luowensheng/.rvm/rubies/ruby-2.3.3'
PATH = '/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/luowensheng/.rvm/gems/ruby-2.3.3/bin:/Users/luowensheng/.rvm/gems/ruby-2.3.3@global/bin:/Users/luowensheng/.rvm/rubies/ruby-2.3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/luowensheng/.rvm/gems/ruby-2.3.3/bin:/Users/luowensheng/.rvm/gems/ruby-2.3.3@global/bin:/Users/luowensheng/.rvm/rubies/ruby-2.3.3/bin:/usr/local/mysql/bin:/usr/local/Cellar/go/1.7.6/bin:/Users/luowensheng/.rvm/bin:/usr/local/mysql/bin:/usr/local/Cellar/go/1.7.6/bin:/Users/luowensheng/.rvm/bin:/Users/luowensheng/.rvm/bin'
PATH_INFO = u'/sendOrder/'
PWD = '/Users/luowensheng/Desktop/TestIOS/TestPython/gjjWeb'
QUERY_STRING = ''
REMOTE_ADDR = '127.0.0.1'
REMOTE_HOST = ''
REQUEST_METHOD = 'POST'
RUBY_VERSION = 'ruby-2.3.3'
RUN_MAIN = 'true'
SCRIPT_NAME = u''
SERVER_NAME = '1.0.0.127.in-addr.arpa'
SERVER_PORT = '8000'
SERVER_PROTOCOL = 'HTTP/1.1'
SERVER_SOFTWARE = 'WSGIServer/0.1 Python/2.7.10'
SHELL = '/bin/bash'
SHLVL = '1'
SSH_AUTH_SOCK = '/private/tmp/com.apple.launchd.lRcMASE9yj/Listeners'
TERM = 'xterm-256color'
TMPDIR = '/var/folders/qp/h96_smbd55ggtzwvml8wpl9h0000gn/T/'
TZ = 'UTC'
USER = 'ldl'
VERSIONER_PYTHON_PREFER_32_BIT = 'no'
VERSIONER_PYTHON_VERSION = '2.7'
XPC_FLAGS = '0x0'
XPC_SERVICE_NAME = '0'
_ = '/usr/bin/python'
__CF_USER_TEXT_ENCODING = '0x1F5:0x19:0x34'
_system_arch = 'x86_64'
_system_name = 'OSX'
_system_type = 'Darwin'
_system_version = '10.12'
rvm_bin_path = '/Users/luowensheng/.rvm/bin'
rvm_loaded_flag = '1'
rvm_path = '/Users/luowensheng/.rvm'
rvm_prefix = '/Users/luowensheng'
rvm_stored_umask = '0022'
rvm_user_install_flag = '1'
rvm_version = '1.29.1 (latest)'
wsgi.errors = <open file '<stderr>', mode 'w' at 0x10f61e1e0>
wsgi.file_wrapper = ''
wsgi.input = <socket._fileobject object at 0x1109e2ed0>
wsgi.multiprocess = False
wsgi.multithread = True
wsgi.run_once = False
wsgi.url_scheme = 'http'
wsgi.version =
Settings:
Using settings module gjjWeb.settings
ABSOLUTE_URL_OVERRIDES = {}
ADMINS = []
ALLOWED_HOSTS = []
APPEND_SLASH = True
AUTHENTICATION_BACKENDS = [u'django.contrib.auth.backends.ModelBackend']
AUTH_PASSWORD_VALIDATORS = u'********************'
AUTH_USER_MODEL = u'auth.User'
BASE_DIR = '/Users/luowensheng/Desktop/TestIOS/TestPython/gjjWeb'
CACHES = {u'default': {u'BACKEND': u'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS = u'default'
CACHE_MIDDLEWARE_KEY_PREFIX = u'********************'
CACHE_MIDDLEWARE_SECONDS = 600
CSRF_COOKIE_AGE = 31449600
CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_NAME = u'csrftoken'
CSRF_COOKIE_PATH = u'/'
CSRF_COOKIE_SECURE = False
CSRF_FAILURE_VIEW = u'django.views.csrf.csrf_failure'
CSRF_HEADER_NAME = u'HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS = []
CSRF_USE_SESSIONS = False
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'NAME': '/Users/luowensheng/Desktop/TestIOS/TestPython/gjjWeb/db.sqlite3', 'CONN_MAX_AGE': 0, 'TIME_ZONE': None, 'OPTIONS': {}, 'HOST': '', 'USER': '', 'TEST': {'COLLATION': None, 'CHARSET': None, 'NAME': None, 'MIRROR': None}, 'PASSWORD': u'********************', 'PORT': ''}}
DATABASE_ROUTERS = []
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000
DATETIME_FORMAT = u'N j, Y, P'
DATETIME_INPUT_FORMATS = [u'%Y-%m-%d %H:%M:%S', u'%Y-%m-%d %H:%M:%S.%f', u'%Y-%m-%d %H:%M', u'%Y-%m-%d', u'%m/%d/%Y %H:%M:%S', u'%m/%d/%Y %H:%M:%S.%f', u'%m/%d/%Y %H:%M', u'%m/%d/%Y', u'%m/%d/%y %H:%M:%S', u'%m/%d/%y %H:%M:%S.%f', u'%m/%d/%y %H:%M', u'%m/%d/%y']
DATE_FORMAT = u'N j, Y'
DATE_INPUT_FORMATS = [u'%Y-%m-%d', u'%m/%d/%Y', u'%m/%d/%y', u'%b %d %Y', u'%b %d, %Y', u'%d %b %Y', u'%d %b, %Y', u'%B %d %Y', u'%B %d, %Y', u'%d %B %Y', u'%d %B, %Y']
DEBUG = True
DEBUG_PROPAGATE_EXCEPTIONS = False
DECIMAL_SEPARATOR = u'.'
DEFAULT_CHARSET = u'utf-8'
DEFAULT_CONTENT_TYPE = u'text/html'
DEFAULT_EXCEPTION_REPORTER_FILTER = u'django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE = u'django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL = u'webmaster@localhost'
DEFAULT_INDEX_TABLESPACE = u''
DEFAULT_TABLESPACE = u''
DISALLOWED_USER_AGENTS = []
EMAIL_BACKEND = u'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = u'localhost'
EMAIL_HOST_PASSWORD = u'********************'
EMAIL_HOST_USER = u''
EMAIL_PORT = 25
EMAIL_SSL_CERTFILE = None
EMAIL_SSL_KEYFILE = u'********************'
EMAIL_SUBJECT_PREFIX = u'[Django] '
EMAIL_TIMEOUT = None
EMAIL_USE_LOCALTIME = False
EMAIL_USE_SSL = False
EMAIL_USE_TLS = False
FILE_CHARSET = u'utf-8'
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
FILE_UPLOAD_HANDLERS = [u'django.core.files.uploadhandler.MemoryFileUploadHandler', u'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440
FILE_UPLOAD_PERMISSIONS = None
FILE_UPLOAD_TEMP_DIR = None
FIRST_DAY_OF_WEEK = 0
FIXTURE_DIRS = []
FORCE_SCRIPT_NAME = None
FORMAT_MODULE_PATH = None
FORM_RENDERER = u'django.forms.renderers.DjangoTemplates'
IGNORABLE_404_URLS = []
INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'frontend']
INTERNAL_IPS = []
LANGUAGES = [(u'af', u'Afrikaans'), (u'ar', u'Arabic'), (u'ast', u'Asturian'), (u'az', u'Azerbaijani'), (u'bg', u'Bulgarian'), (u'be', u'Belarusian'), (u'bn', u'Bengali'), (u'br', u'Breton'), (u'bs', u'Bosnian'), (u'ca', u'Catalan'), (u'cs', u'Czech'), (u'cy', u'Welsh'), (u'da', u'Danish'), (u'de', u'German'), (u'dsb', u'Lower Sorbian'), (u'el', u'Greek'), (u'en', u'English'), (u'en-au', u'Australian English'), (u'en-gb', u'British English'), (u'eo', u'Esperanto'), (u'es', u'Spanish'), (u'es-ar', u'Argentinian Spanish'), (u'es-co', u'Colombian Spanish'), (u'es-mx', u'Mexican Spanish'), (u'es-ni', u'Nicaraguan Spanish'), (u'es-ve', u'Venezuelan Spanish'), (u'et', u'Estonian'), (u'eu', u'Basque'), (u'fa', u'Persian'), (u'fi', u'Finnish'), (u'fr', u'French'), (u'fy', u'Frisian'), (u'ga', u'Irish'), (u'gd', u'Scottish Gaelic'), (u'gl', u'Galician'), (u'he', u'Hebrew'), (u'hi', u'Hindi'), (u'hr', u'Croatian'), (u'hsb', u'Upper Sorbian'), (u'hu', u'Hungarian'), (u'ia', u'Interlingua'), (u'id', u'Indonesian'), (u'io', u'Ido'), (u'is', u'Icelandic'), (u'it', u'Italian'), (u'ja', u'Japanese'), (u'ka', u'Georgian'), (u'kk', u'Kazakh'), (u'km', u'Khmer'), (u'kn', u'Kannada'), (u'ko', u'Korean'), (u'lb', u'Luxembourgish'), (u'lt', u'Lithuanian'), (u'lv', u'Latvian'), (u'mk', u'Macedonian'), (u'ml', u'Malayalam'), (u'mn', u'Mongolian'), (u'mr', u'Marathi'), (u'my', u'Burmese'), (u'nb', u'Norwegian Bokm\xe5l'), (u'ne', u'Nepali'), (u'nl', u'Dutch'), (u'nn', u'Norwegian Nynorsk'), (u'os', u'Ossetic'), (u'pa', u'Punjabi'), (u'pl', u'Polish'), (u'pt', u'Portuguese'), (u'pt-br', u'Brazilian Portuguese'), (u'ro', u'Romanian'), (u'ru', u'Russian'), (u'sk', u'Slovak'), (u'sl', u'Slovenian'), (u'sq', u'Albanian'), (u'sr', u'Serbian'), (u'sr-latn', u'Serbian Latin'), (u'sv', u'Swedish'), (u'sw', u'Swahili'), (u'ta', u'Tamil'), (u'te', u'Telugu'), (u'th', u'Thai'), (u'tr', u'Turkish'), (u'tt', u'Tatar'), (u'udm', u'Udmurt'), (u'uk', u'Ukrainian'), (u'ur', u'Urdu'), (u'vi', u'Vietnamese'), (u'zh-hans', u'Simplified Chinese'), (u'zh-hant', u'Traditional Chinese')]
LANGUAGES_BIDI = [u'he', u'ar', u'fa', u'ur']
LANGUAGE_CODE = 'en-us'
LANGUAGE_COOKIE_AGE = None
LANGUAGE_COOKIE_DOMAIN = None
LANGUAGE_COOKIE_NAME = u'django_language'
LANGUAGE_COOKIE_PATH = u'/'
LOCALE_PATHS = []
LOGGING = {}
LOGGING_CONFIG = u'logging.config.dictConfig'
LOGIN_REDIRECT_URL = u'/accounts/profile/'
LOGIN_URL = u'/accounts/login/'
LOGOUT_REDIRECT_URL = None
MANAGERS = []
MEDIA_ROOT = u''
MEDIA_URL = u''
MESSAGE_STORAGE = u'django.contrib.messages.storage.fallback.FallbackStorage'
MIDDLEWARE = ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
MIDDLEWARE_CLASSES = [u'django.middleware.common.CommonMiddleware', u'django.middleware.csrf.CsrfViewMiddleware']
MIGRATION_MODULES = {}
MONTH_DAY_FORMAT = u'F j'
NUMBER_GROUPING = 0
PASSWORD_HASHERS = u'********************'
PASSWORD_RESET_TIMEOUT_DAYS = u'********************'
PREPEND_WWW = False
PRODUCT_PAGE_SIZE = 3
ROOT_URLCONF = 'gjjWeb.urls'
SECRET_KEY = u'********************'
SECURE_BROWSER_XSS_FILTER = False
SECURE_CONTENT_TYPE_NOSNIFF = False
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_PROXY_SSL_HEADER = None
SECURE_REDIRECT_EXEMPT = []
SECURE_SSL_HOST = None
SECURE_SSL_REDIRECT = False
SERVER_EMAIL = u'root@localhost'
SESSION_CACHE_ALIAS = u'default'
SESSION_COOKIE_AGE = 1209600
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_NAME = u'sessionid'
SESSION_COOKIE_PATH = u'/'
SESSION_COOKIE_SECURE = False
SESSION_ENGINE = u'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_FILE_PATH = None
SESSION_SAVE_EVERY_REQUEST = False
SESSION_SERIALIZER = u'django.contrib.sessions.serializers.JSONSerializer'
SETTINGS_MODULE = 'gjjWeb.settings'
SHORT_DATETIME_FORMAT = u'm/d/Y P'
SHORT_DATE_FORMAT = u'm/d/Y'
SIGNING_BACKEND = u'django.core.signing.TimestampSigner'
SILENCED_SYSTEM_CHECKS = []
STATICFILES_DIRS = '/Users/luowensheng/Desktop/TestIOS/TestPython/gjjWeb/static'
STATICFILES_FINDERS = [u'django.contrib.staticfiles.finders.FileSystemFinder', u'django.contrib.staticfiles.finders.AppDirectoriesFinder']
STATICFILES_STORAGE = u'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT = None
STATIC_URL = '/static/'
TEMPLATES = [{'DIRS': ['/Users/luowensheng/Desktop/TestIOS/TestPython/gjjWeb/templates'], 'APP_DIRS': True, 'OPTIONS': {'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages']}, 'BACKEND': 'django.template.backends.django.DjangoTemplates'}]
TEST_NON_SERIALIZED_APPS = []
TEST_RUNNER = u'django.test.runner.DiscoverRunner'
THOUSAND_SEPARATOR = u','
TIME_FORMAT = u'P'
TIME_INPUT_FORMATS = [u'%H:%M:%S', u'%H:%M:%S.%f', u'%H:%M']
TIME_ZONE = 'UTC'
USE_ETAGS = False
USE_I18N = True
USE_L10N = True
USE_THOUSAND_SEPARATOR = False
USE_TZ = True
USE_X_FORWARDED_HOST = False
USE_X_FORWARDED_PORT = False
WINERYCONSULT_PAGE_SIZE = 6
WSGI_APPLICATION = 'gjjWeb.wsgi.application'
X_FRAME_OPTIONS = u'SAMEORIGIN'
YEAR_MONTH_FORMAT = u'F Y'
You're seeing this error because you have DEBUG = True in your
Django settings file. Change that to False, and Django will
display a standard page generated by the handler for this status code.
修改-2
在views.py
:
def sendOrder(request):
if request.method == 'POST':
pass
username = request.POST.get('username')
tel = request.POST.get('tel')
email = request.POST.get('email')
address = request.POST.get('address')
content = request.POST.get('content')
_user = "726535609@qq.ocm"
_pwd = "liaodalin19903"
_to = "liaodalin19903@126.com"
email_content = "用户名:" + username + "/n" + \
"电话:" + tel +"/n" + \
"邮件:" + email + "/n" + \
"地址:" + address + "/n" + \
"内容:" + content + "/n"
msg = MIMEText(email_content) # This is the 204 line.
msg["Subject"] = "订购高家酒"
msg["From"] = _user
msg["To"] = _to
try:
s = smtplib.SMTP_SSL("smtp.qq.com", 465)
s.login(_user, _pwd)
s.sendmail(_user, _to, msg.as_string())
s.quit()
return {"result":"1", "msg": "发送成功!" }
except smtplib.SMTPException, e:
return {"result":"0", "msg":e}
修改-3
我更改了views.py
:
email_content = u'用户名:' + username + '\n' + \
u'电话:' + tel +'\n' + \
u'邮件:' + email + '\n' + \
u'地址:' + address + '\n' + \
u'内容:' + content + '\n'
但仍然无效。
答案 0 :(得分:0)
尝试设置编码:
msg = MIMEText(email_content, "plain", "utf-8")