Django Admin Site:

  • You can work with your models through the admin site.

How to Create a Superuser:

  • To create a superuser in Django, enter the following command and respond to the prompts:
1python manage.py createsuperuser
  • Terminal Interaction:
1Username (leave blank to use 'wkapakos'): cj_admin
2Email address: wakapakos@wcu.edu
3Password:
4Password (again):
5This password is too common.
6Bypass password validation and create user anyway? [y/N]: y
7Superuser created successfully.

Register a Model with the Admin Site:

  • Open the file admin.py to look at its existing content:

admin.py

python
1from django.contrib import admin
2
3# Register your models here.
  • Register Topic with the admin site:

admin.py

python
1from django.contrib import admin
2	
3from code_journals.models import Topic
4 
5admin.site.register(Topic)
  • This code imports the model we want to register, Topic, and then uses admin.site.register() to tell Django to manage our model through the admin site.

To Access the Admin Site:

  • (First, make sure that the project is running) then use the superuser account to access the admin site: