Those reading this via a feed reader will have to view the page on my blog as I am using embedded gists. I'll find a solution for that in the future.
So say you have a base template that looks something like:
And a template that looks like either of these:
It used to be that you could write something like this:
But generic function based views are deprecated and the world is being strongly urged to move to generic class based views. If you would like to get extra_content working with the direct_to_template replacement TemplateView, you can use a view like the following:
And a urls.py like the following using it:
The code used in this blog post can be found in this gist.
It's seems that you forgotten to type "other" address in old_urls.py
ReplyDeleteThanks, corrected.
DeleteDid you mean "move to generic class based views" here "move to generic calls based views"?
ReplyDeleteThanks, corrected.
DeleteNice example. I like the usage of the View.__init__() constructor here to pass values to the view, didn't think about using it like that.
ReplyDeleteIt is actually the code in View.as_view() that is handling the assignment of arguments to members of the class.
Deletehttps://github.com/django/django/blob/master/django/views/generic/base.py#L30
I really enjoyed your blog post! I was wondering if you would be interested in having it featured on DZone.com. If so, please contact me for more information. Thanks!
ReplyDelete