Custom error pages in GAE/Django
April 11, 2008 – 8:38 amTo allow for custom error pages (404,500) in Django/Google App Engine all you need is this bit of middle-ware that stubs out the request class for you so that it doesn’t blow up.
Add your custom templates to your template directory and name them 404.html, 500.html etc.
Paste the following into middleware/errorpages.py
1 2 3 4 5 6 7 8 9 | class DummyUser(object): def get_and_delete_messages(self): pass class NeedsUserObject(object): def process_request(self, request): request.user = DummyUser() |
In your settings.py add the NeedsUserObject middleware
MIDDLEWARE_CLASSES = ( ... 'middleware.errorpages.NeedsUserObject', )
You must be logged in to post a comment.