[Answer]-Check admin login on my django app

1👍

Use the @staff_member_required decorator:

from django.contrib.admin.views.decorators import staff_member_required

@staff_member_required
def my_view(request):
    ...

0👍

from django.contrib.auth.decorators import user_passes_test

@user_passes_test(lambda u:u.is_staff, login_url='/foo/')
def staff_view(request..):
    ...

Leave a comment