Wednesday, October 5, 2011

Re: TemplateView compatible with permission_required decorator?

Instead, you should decorate the dispatch method in the class-based
view. See the docs here:

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

On Oct 5, 10:27 am, Victor Hooi <victorh...@gmail.com> wrote:
> Hi,
>
> I'm attempting to use one of the new class-based TemplateView with the
> permission_required decorator:
>
> @permission_required('foo.count_peas')
> class Pea(TemplateView):
>     template_name = "pea.html"
>
> However, when I do that, I get an error:
>
> Exception Type: AttributeError at /someurl/
> Exception Value: 'function' object has no attribute 'as_view'
>
> If I comment out the permission_required decorator, the view seems to work
> fine.
>
> Are the new class-based views compatible with the permission_required
> decorator?
>
> Or is there something I need to do to make them work together.
>
> Cheers,
> Victor

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