Django Superuser : How To Create Superuser In Django

Django superuser is a very powerful tool which provide us with many things as a user.

In django a user can be allowed to be a superuser or a staff or just a user. in this same aspect when a user is just a staff some roles can be assigned to the user with explicit assignment.

That MEANS one’s the user is assigned the role, it has the right to do whatever the super user can do with the roles assigned to at that time. Some people confuse superuser to root user, the two are the same.

Django Slug Field : How To Auto Populate Django Slug

How To Install Social Engineering Toolkits (Set) In Nethunter Kali Linux

Types of Users in Django.

  • Superuser– Superuser has all the roles and rights assigned by default
  • Staff User– This user some roles and rights are assigned by the superuser
  • Ordinary User– This user can only be logged in outside Django admin and would only access what ever it is only allowed to access

A Superuser – Is defined as themost powerful user which all roles are beign assigned by default with permissions to create, read, update and delete data in the Django admin, which includes model records and other users.

Steps or process involved in creating a superuser in django

  • Create a virtual environment and activate it
  • Install django
  • Start a project then start an app
  • Run./manage.py runserverto see if everything is alright If so quit and
  • Run python manage.py migrate
  • Runpython manage.py createsuperuserinput your email, password and username
  • Run python manage.py makemigrations
  • Run python manage.py migrate

Illustration of how to create superuser in django

Create a virtual Environment in any of your code editor and activate

Start a django web app project

Lets create a django project and name it mysite and start an app and name it myapp.

To complete the steps above studyhere

Lets run migrations

python manage.py makemigration

python manage.py migrate

Create a Django superuser

Use this command below to create a superuser

python manage.py createauperuser
#Enter your preferred username, email and password when prompt. if you skip username the default user name will be the device name. 

Now you have to run another migration then login into your admin panel

python manage.py migrate

python manage.py runserver

#locate the admin at localhost:8000/asmin 

Conclusion: We created a virtual environment and activated it , then we also started a django project mysite and django app myapp then created a superuser which is accesible at localhost:8000/admin.

please leave a comment below if there is any confusion

One thought on “Django Superuser : How To Create Superuser In Django

Leave a Reply

Your email address will not be published. Required fields are marked *