У меня есть немного странная проблема с администрацией Django. С DEBUG = True в settings.py все работает нормально. Но когда я меняю его на DEBUG = False, я не могу перейти к редактированию страницы. Я получаю эту ошибку:DjangoUnicodeDecodeError в администрации с DEBUG = False
Traceback (most recent call last):
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py, line 136, in get_response
response = response.render()
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/response.py, line 104, in render
self._set_content(self.rendered_content)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/response.py, line 81, in rendered_content
content = template.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 140, in render
return self._render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 134, in _render
return self.nodelist.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 823, in render
bit = self.render_node(node, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 837, in render_node
return node.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py, line 123, in render
return compiled_parent._render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 134, in _render
return self.nodelist.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 823, in render
bit = self.render_node(node, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 837, in render_node
return node.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py, line 123, in render
return compiled_parent._render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 134, in _render
return self.nodelist.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 823, in render
bit = self.render_node(node, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 837, in render_node
return node.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py, line 62, in render
result = block.nodelist.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 823, in render
bit = self.render_node(node, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 837, in render_node
return node.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py, line 62, in render
result = block.nodelist.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 823, in render
bit = self.render_node(node, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 837, in render_node
return node.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py, line 192, in render
nodelist.append(node.render(context))
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py, line 155, in render
return self.render_template(self.template, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/loader_tags.py, line 137, in render_template
output = template.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 140, in render
return self._render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 134, in _render
return self.nodelist.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 823, in render
bit = self.render_node(node, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 837, in render_node
return node.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py, line 192, in render
nodelist.append(node.render(context))
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py, line 192, in render
nodelist.append(node.render(context))
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py, line 281, in render
return nodelist.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 823, in render
bit = self.render_node(node, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 837, in render_node
return node.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/defaulttags.py, line 281, in render
return nodelist.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 823, in render
bit = self.render_node(node, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 837, in render_node
return node.render(context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 880, in render
return _render_value_in_context(output, context)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/template/base.py, line 858, in _render_value_in_context
value = force_unicode(value)
File /home/yetty/projects/Tchorici/venv/local/lib/python2.7/site-packages/django/utils/encoding.py, line 93, in force_unicode
raise DjangoUnicodeDecodeError(s, *e.args)
DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128). You passed in <django.forms.forms.BoundField object at 0x327bd90> (<class 'django.forms.forms.BoundField'>)
Я понятия не имею, почему я его просто с DEBUG = False.
Я бы сказал, что кодирование веб-страниц - это одно, а другое - кодирование базы данных. Проверьте сопоставление и кодировку вашей базы данных – matcheek
Вы используете Django, что означает, что вы все еще используете версию Python до 3.0, что, в свою очередь, означает, что вам нужно [отметить строки Unicode] (http://docs.python.org/howto /unicode.html#the-unicode-type). Используйте 'u" Účastníci "' вместо '' Účastníci'', и он должен работать. – roam
Я проверил сортировки - все в порядке. Знак Unicode не работает. Повторяю - все только с DEBUG = False, с DEBUG = True работает нормально. – yetty