Create an admin site for our django project

created at 02-27-2021 views: 8

Fortunately, we do not need to do much work to create an admin site for our django project, because admin is a built-in app of Django and we can use it directly.

where is admin located ?

let' go to our django package and have a look at the structure:

    ├── django
    │   ├── apps
    │   ├── bin
    │   ├── conf
    │   └── contrib
    │       ├── admin

we can see the built-in admin app located in django > contrib 

install admin

add admin into INSTALLED_APPS in


also notice some packages are also needed:


include urls of admin

to include urls of admin, we should import admin first:

from django.contirb import admin

urlpatterns = [
    path('admin/',, # note: no quotation mark


before we can create a superuser, we need to make migrations for admin app first, or you will get an error like:

You have 3 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin.
Run 'python migrate' to apply them.

so, let's migrate first:

python3 migrate admin

# results:
Running migrations:
 Applying admin.0001_initial... OK
 Applying admin.0002_logentry_remove_auto_add... OK
 Applying admin.0003_logentry_add_action_flag_choices... OK

create superuser

go to the root directory of our django project (where located) and run:

python3 createsuperuser

# fill in some information
Email address: 
Password (again): 

now, you can access your admin site through

created at:02-27-2021
edited at: 03-05-2021: