Wednesday, October 5, 2011

TemplateView compatible with permission_required decorator?

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 view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/BLrtdUAyciYJ.
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