Last change
on this file since 0445831 was
5f82b6c,
checked in by Alex Dehnert <adehnert@…>, 11 years ago
|
Replace ListViewWithContext? with simpler render_to_response
It turns out that if you're specifying a queryset and a bunch of extra context,
ListView? isn't *actually* buying much...
|
-
Property mode set to
100644
|
File size:
743 bytes
|
Line | |
---|
1 | from django.http import HttpResponseForbidden |
---|
2 | from django.template import RequestContext, Template |
---|
3 | from django.template.loader import get_template |
---|
4 | from django.views.generic.base import TemplateView |
---|
5 | from django.views.generic.list import ListView |
---|
6 | |
---|
7 | def get_403_response(request, errmsg=None, **extra_context): |
---|
8 | tmpl = get_template('403.html') |
---|
9 | ctx = RequestContext(request, dict(errmsg=errmsg, **extra_context)) |
---|
10 | page = tmpl.render(ctx, ) |
---|
11 | return HttpResponseForbidden(page) |
---|
12 | |
---|
13 | |
---|
14 | class TemplateViewWithContext(TemplateView): |
---|
15 | extra_context = {} |
---|
16 | |
---|
17 | def get_context_data(self, **kwargs): |
---|
18 | context = super(TemplateViewWithContext,self).get_context_data(**kwargs) |
---|
19 | print context |
---|
20 | context.update(self.extra_context) |
---|
Note: See
TracBrowser
for help on using the repository browser.