从here开始,我改变了我的模型:
class MyModel(User):
class Meta:
verbose_name=u"my app verbose name"
app_label = u"My Members"
db_table = "members_mymodel"
现在我在django admin中找到应用程序时遇到错误:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/django/core/servers/basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)
File "/Library/Python/2.6/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
return self.application(environ, start_response)
File "/Library/Python/2.6/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/Library/Python/2.6/site-packages/django/core/handlers/base.py", line 146, in get_response
response = debug.technical_404_response(request, e)
File "/Library/Python/2.6/site-packages/django/views/debug.py", line 294, in technical_404_response
'reason': smart_str(exception, errors='replace'),
File "/Library/Python/2.6/site-packages/django/utils/encoding.py", line 123, in smart_str
errors) for arg in s])
File "/Library/Python/2.6/site-packages/django/utils/encoding.py", line 124, in smart_str
return unicode(s).encode(encoding, errors)
File "/Library/Python/2.6/site-packages/django/core/urlresolvers.py", line 191, in __repr__
return '<%s %s (%s:%s) %s>' % (self.__class__.__name__, self.urlconf_name, self.app_name, self.namespace, self.regex.pattern)
File "/Library/Python/2.6/site-packages/django/core/urlresolvers.py", line 191, in __repr__
return '<%s %s (%s:%s) %s>' % (self.__class__.__name__, self.urlconf_name, self.app_name, self.namespace, self.regex.pattern)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0130' in position 17: ordinal not in range(128)
管理员链接:
http://localhost:8000/admin/My%20Members/
我该如何解决这个问题?
提前致谢
答案 0 :(得分:0)
听起来你的代码库中有一个奇怪的字符(\u0130
)。那个角色是“拉丁大写字母,上面有一个点”:İ。尝试搜索并删除它。
如果您在.py
文件中使用UTF-8字符,请将其添加为第一行,将其声明为UTF-8:
# -*- coding: utf-8 -*-