djangosuperuser

How do I make a webpage be different for a superuser and a normal user on django?


Let me explain a little, I'm trying to make a website just for practicing, in which you have two sides, customer-side, and admin-side, so I want to make certain pages display certain functions when you are logged in as an admin, and to not display said functions to normal users, such as edits and stuff. How do I do that?

I hope I explained it properly. Thanks.


Solution

  • yes, Here is what you have asked for

    in your template

    hello.html

    {% if user.is_superuser or user.is_staff %}
    This section only visible to superuser and staff
    This section not accessible to normal users
    {% endif %}