Wagtail: Deployment Issue - KeyError 'request' on /admin
Asked Answered
S

1

1

I'm deploying a site using Wagtail CMS on a webfaction server. When I try to go to www.mysite.com/admin (wagatil admin interfase) it give me a 500 error. I can go to django's admin with no problem.

I looked at the server logs and what it says is the it raise a KeyError for the 'request' key. This happens only when Debug is True, I changed it to False and the /admin was rendered correctly.

I verified that the 'django.core.context_processors.request' is added in the TEMPLATE_CONTEXT_PROCESSORS setting.

here is the traceback from the server logs

[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1] mod_wsgi (pid=21360): Exception occurred processing WSGI script '/home/frodriguez/webapps/djblog/myproject/myproject/wsgi.py'.
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1] Traceback (most recent call last):
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     response = self.get_response(request)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 194, in get_response
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     return callback(request, **param_dict)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 99, in _wrapped_view
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     response = view_func(request, *args, **kwargs)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/views/defaults.py", line 46, in server_error
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     return http.HttpResponseServerError(template.render(Context({})))
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/base.py", line 140, in render
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     return self._render(context)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     return self.nodelist.render(context)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/base.py", line 840, in render
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     bit = self.render_node(node, context)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/base.py", line 854, in render_node
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     return node.render(context)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/loader_tags.py", line 123, in render
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     return compiled_parent._render(context)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     return self.nodelist.render(context)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/base.py", line 840, in render
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     bit = self.render_node(node, context)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/base.py", line 854, in render_node
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     return node.render(context)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/base.py", line 1125, in render
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     return func(*resolved_args, **resolved_kwargs)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/wagtail/wagtailadmin/templatetags/wagtailuserbar.py", line 15, in wagtailuserbar
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     request = context['request']
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]   File "/home/frodriguez/.virtualenvs/venv/lib/python2.7/site-packages/django/template/context.py", line 56, in __getitem__
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1]     raise KeyError(key)
[Fri Nov 07 15:33:58 2014] [error] [client 127.0.0.1] KeyError: 'request'

Does anyone know what am I missing?

Souffle answered 7/11, 2014 at 22:5 Comment(0)
S
3

Just in case anyone is having this issue I´m answering myself.

This was a 2-part problem.

1-) I was extending from base.html in my 500.html template.

Removing that than showed me the real error, which was that the compress app was not compressing the files, so you have to do the following

2.) run python manage.py compress --force

After that admin site was rendering with DEBUG=False with no problem.

Souffle answered 24/1, 2015 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.