Answer the question
In order to leave comments, you need to log in
How to set permission for own method?
Good, community.
There are two methods:
def list(self, request, *args, **kwargs):
pass
def manager_objects(self, request, *args, **kwargs):
pass
url('^objects/(?P<user_id>\d+)$', MySuperView.as_view({'get': 'manager_objects'}), name='get_my_objects')
url(r'^all_objects/$', MySuperView.as_view({'get': 'list'})),
Answer the question
In order to leave comments, you need to log in
In your special case, you can apply decoration directly in urls.py, as shown here , only the decorator will be permission_required
But in general, such an approach - to cram everything into one view and put some logic in urls.py - would be rejected :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question