[Answer]-Function permitted to be run by admin only in Django

1👍

It should wrapped inside a admin.site.admin_view.

from django.contrib.admin.site import admin_view
url(r'^admin/dummyfx', admin_view('dummy.views.dummyfx')),
👤kasun

0👍

You should use user_passes_test decorator for your view user_passes_test Docs

Something like that:

@user_passes_test(lambda u: u.is_superuser)
def my_view(request):
     ...................
     ....................
👤kpacn

Leave a comment