3

我对 Django 管理有一点奇怪的问题。在 settings.py 中使用 DEBUG=True,一切正常。但是当我将其更改为 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 得到它。

4

2 回答 2

5

我有它;)

在 admin.py 中,我有自己的 MultipleChoiceField 表单:

people = forms.ModelMultipleChoiceField(
    Person.objects.all(),
    widget=FilteredSelectMultiple("Účastníci", False, attrs={'rows': '10'})
)

class Meta:
    model = Event

即使我有

# -*- coding: utf-8 -*-

在文件的开头,“Účastníci”制造了麻烦。当我将其更改为“Ucastnici”时,一切正常。

于 2012-07-02T08:34:03.270 回答
-1

我通过实验发现错误是debug_toolbar. 带DEBUG=True debug_toolbar残疾人

于 2014-04-11T11:14:05.123 回答