0

花了几个小时试图解决这个问题,但我不能......让我发疯。任何提示都非常感谢。

在我部署我的应用程序后的 heroku 上,所有表在 django-admin 中似乎都可以正常工作 - 就在 syncdb 之后。但是在我使用 db:push sqlite://myapp.db 添加数据后,我在 admin/auth/user/ 上出现错误。其他表和应用程序仍然有效。我没有对身份验证/用户进行任何更改。

Environment:


Request Method: GET
Request URL: http://sharp-frost-3799.herokuapp.com/admin/auth/user/
Django Version: 1.3.1 Python Version: 2.7.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_nose', 'fftests', 'django.contrib.admin'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfResponseMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')

Template error: In template /app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/templates/admin/change_list.html, error at line 97 Caught KeyError while rendering: u'true' 87 : {% endif %}

88 : {% endblock %}

89 :

90 : {% csrf_token %}

91 : {% if cl.formset %}

92 : {{ cl.formset.management_form }}

93 : {% endif %}

94 :

95 : {% block result_list %}

96 : {% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}

97 : {% result_list cl %}

98 : {% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}

99 : {% endblock %}

100 : {% block pagination %}{% pagination cl %}{% endblock %}

101 :

102 :

103 :

104 : {% endblock %}

105 :

Traceback: File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper 307. return self.admin_site.admin_view(view)(*args, **kwargs) File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 93. response = view_func(request, *args, **kwargs) File "/app/.heroku/venv/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 79. response = view_func(request, *args, **kwargs) File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner 197. return view(request, *args, **kwargs) File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper 28. return bound_func(*args, **kwargs) File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 93. response = view_func(request, *args, **kwargs) File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func 24. return func(self, *args2, **kwargs2) File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/options.py" in changelist_view 1179. ], context, context_instance=context_instance) File "/app/.heroku/venv/lib/python2.7/site-packages/django/shortcuts/init.py" in render_to_response 20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/loader.py" in render_to_string 188. return t.render(context_instance) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in render 123. return self._render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in _render 117. return self.nodelist.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in render 744. bits.append(self.render_node(node, context)) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/debug.py" in render_node 73. result = node.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/loader_tags.py" in render 127. return compiled_parent._render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in _render 117. return self.nodelist.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in render 744. bits.append(self.render_node(node, context)) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/debug.py" in render_node 73. result = node.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/loader_tags.py" in render 127. return compiled_parent._render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in _render 117. return self.nodelist.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in render 744. bits.append(self.render_node(node, context)) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/debug.py" in render_node 73. result = node.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/loader_tags.py" in render 64. result = block.nodelist.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in render 744. bits.append(self.render_node(node, context)) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/debug.py" in render_node 73. result = node.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/loader_tags.py" in render 64. result = block.nodelist.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in render 744. bits.append(self.render_node(node, context)) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/debug.py" in render_node 73. result = node.render(context) File "/app/.heroku/venv/lib/python2.7/site-packages/django/template/base.py" in render 921. dict = func(*args) File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in result_list 232. 'results': list(results(cl))} File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in results 217. yield ResultList(None, items_for_result(cl, res, None)) File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in init 209. super(ResultList, self).init(*items) File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in items_for_result 165. result_repr = display_for_field(value, f) File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/util.py" in display_for_field 285. return _boolean_icon(value) File "/app/.heroku/venv/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in _boolean_icon 126. return mark_safe(u'' % (settings.ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val))

Exception Type: TemplateSyntaxError at /admin/auth/user/ Exception Value: Caught KeyError while rendering: u'true'
4

1 回答 1

0

仍然不清楚是什么导致了这个问题,但是一旦我从本地的 sqlite 转移到 postgres,它就消失了。现在通过 db:push 推送数据,一切正常。实际上 Heroku 建议也使用 postgres 进行开发。

于 2012-04-06T15:53:10.683 回答