Friday, December 3, 2010

Re: Named URLs and class-based generic views

Forgot to in mention the actual question from the subject.

Is there a "blessed" way to use class-based views with named urls in
the
> url(r'^location/$', view='WouldLoveToHaveClassBasedView.as_view', name='name_for_convenience')

On Dec 3, 1:46 pm, Andrew Willey <and...@apt9online.com> wrote:
> Can someone point me in the right direction here?
>
> How does one use class-based generic views and named URLs?
>
> Example (doesn't work):
>
> > urls.py
> > urlpatterns += patterns('myapp.views',
> >    (r'^location/$', MyGenericView.as_view()),
> > )
> > views.py
> > class MyGenericView(TemplateView):
> >    template_name = 'example.html'
>
> Now, I can make that work if I did this instead in
>
> > urls.py
> > from myapp.views import *
> > urlpatterns += patterns('',
> >     (r'^location/$', MyGenericView.as_view()),
> > )
>
> That approach just feels weird, am I doing it wrong or is that the new
> normal?

--
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


Real Estate