1👍
You can use user_passes_test decorator:
Then you can create an admin_check
method like so:
def admin_check(user):
return user.is_superuser
Pass the admin_check
method to the decorator like so:
@user_passes_test(admin_check)
def my_view(request):
...
- [Answered ]-Django admin: filtering by "now" in list view
- [Answered ]-Datetime received a naive datetime whereas I precised before the timezone
- [Answered ]-Execute raw SQL after connect to database
- [Answered ]-How to continue developement of live Django Webapp?
- [Answered ]-Pinax & Apache: deliver Attachments only to authenticated users
Source:stackexchange.com