Re: [Django 1.3] django.views.generic.TemplateView example
Ack! Russ, I missed this e-mail! I am so sorry for the late reply!
Thanks so much for helping me out, I really appreciate it. :)
On Fri, Sep 30, 2011 at 9:08 PM, Russell Keith-Magee
<russell@keith-magee.com> wrote:
> There's no need to subclass TemplateView and provide your own implementation
> of get_context_data() - the default TemplateView implementation does exactly
> (and I mean character-for-character exactly) what you've defined. So, you
> just need to deploy a default TemplateView in your urls.py:
Hehe! Thanks so much for pointing that out! I should have visited the
source code before posting my question. :(
It's funny, I was just going to reply to the list with my latest
solution... Long story short, my co-worker shared this code:
urlpatterns = patterns('',
(r'^phone-list/$', ListView.as_view(
queryset=Staffer.objects.filter(active=True).order_by('last_name'),
)),
)
... and that motivated me to read the source code [1] and write this
in my urls.py:
from django.views import generic
...
(r'^(?P<id>[a-zA-Z0-9]{32})/$', generic.TemplateView.as_view(
template_name='wire/feed.html',
)),
...
Exactly what you suggested that I do!
That's great though. Thank you for taking the time to help me out, I
really appreciate it. :)
> I know the class-based views docs aren't as good as they could be - thats
> mostly my fault. I also know that "read the source" isn't a real
> documentation answer. However, the CBV code is quite well documented
> internally, and isn't all that complex at the end of the day - if you've got
> questions about how to do something obscure with CBVs, a quick peruse of the
> source is well worth your time.
That works for me! Like I said above, I should have read the source
code before bugging the group. It's amazing how clear things can be
when reading the Django source code.
From now on, I will be sure to go to the code before asking questions. :D
Thanks again! Have an awesome day.
[1] https://code.djangoproject.com/browser/django/trunk/django/views/generic/base.py#L114
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home