How to Create an admin user

Pinterest LinkedIn Tumblr

First, create Model

class Contact(models.Model):
      name = models.CharField(max_length=100)
      email = models.EmailField(max_length=100)
      subject = models.CharField(max_length=100)
      message = models.TextField()
      mobile = models.IntegerField()
      created_date = models.DateField(auto_now_add=True)

Import model within the admin

from django.contrib import admin
from .models import Contact
# Register your models here.

Create superuser

python createsuperuser

Enter your desired username and press enter.

Username: admin

You will then be prompted for your desired email address:

Email address: [email protected]

Start server

python runserver

Write A Comment