Heroku上的Django模板语法错误,而不是Dev

时间:2012-04-05 08:54:21

标签: heroku django-admin

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

在部署我的应用程序后,在heroku上,所有表似乎在django-admin中正常工作 - 就在syncdb之后。但是在我db:push sqlite://myapp.db添加数据后,我在admin / auth / user /上收到错误。其他表和应用程序仍然有效。我没有对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'

1 个答案:

答案 0 :(得分:0)

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