Wednesday, October 5, 2011

Re: Alternative to Decorators for Class-Based View

In the docs there a paragraph or two about this. Basically, one must
decorate the dispatch method instead. See this link for the details.

https://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-the-class

Good luck!

On Oct 5, 11:42 am, Kurtis <kurtis.mull...@gmail.com> wrote:
> Hey,
>
> What's the best way to go about doing things for class-based views
> such as requiring logins? In the function-based views it was easy to
> use decorators.
>
> Should I just replace the functionality that I would previously have
> put into decorators into abstract classes that I extend? If so, can
> someone throw me a simple example?
>
> Not only do I want to have some views require a user to be logged in,
> but I'd like to have other pages require a user to have an active paid
> membership, and so forth ... If there's a better approach to this, let
> me know.
>
> Thanks in advanced!

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

No comments:

Post a Comment