An additional point, if you want to be able to use the view more
generically (be able to pass in custom context from your urls.py), I've
done the following:
class StaticPageView(TemplateView):
context = None
def get_context_data(self, **kwargs):
context = super(StaticPageView, s
Roy, I agree with Fallen that a subclass of TemplateView is required here.
I have used this technique often. Dan
class MyTemplateView(TemplateView):
template_name = 'my_template.html'
def get_context_data(self, **kwargs):
context = super(MyTemplateView, self).get_context_data(*
Take a look at
https://docs.djangoproject.com/en/1.4/topics/generic-views-migration/#extra-context
There's no way for provide an extra_context to a TemplateView. You need to
subclass TemplateView and re-implement get_context_data in the way
described in aforementioned topic.
On Monday, April 23
This should help you out with adding extra context to TemplateView
http://godjango.com/15-class-based-views-part-1-templateview-and-redirectview/
Roy Smith wrote:
I'm using a generic TemplateView (django-1.4), but I want to be able
to add something to the context. Is that possible?
The docs a
Oh, and an extra set of curly braces:
url(r'^about$',
TemplateView.as_view(template_name='legal_ipsum/about.html',
{"extra_content":{"pagename":"about"}})),
On Apr 22, 11:28 pm, Ejah wrote:
> Quotes around extra_context
> HTH
>
> On Apr 22, 11:20 pm, Roy Smith wrote:
>
>
>
>
>
>
>
> > I'm us
Quotes around extra_context
HTH
On Apr 22, 11:20 pm, Roy Smith wrote:
> I'm using a generic TemplateView (django-1.4), but I want to be able to add
> something to the context. Is that possible?
>
> The docs
> athttps://docs.djangoproject.com/en/1.4/topics/generic-views/#adding-ex...talk
> abo
I'm using a generic TemplateView (django-1.4), but I want to be able to add
something to the context. Is that possible?
The docs at
https://docs.djangoproject.com/en/1.4/topics/generic-views/#adding-extra-context
talk about "an extra optional parameter, extra_context", but I don't get what
th
7 matches
Mail list logo