Instagram
youtube
Facebook
Twitter

Django Admin

Django provides an inbuilt admin interface to do administrative activities. To do CRUD operations in our Contacts we have just a module we’ll use Django admin. To register our model in Django admin use the given code.

from Django.contrib import admin

from YourAppName.models import Contact

 

# Register your models here.

admin.site.register(Contact)

Here, firstly we have imported our model in Django admin and registered it.

After registering your model in your Django admin use the following command to create a superuser.

 
\Codersdaily\project1> python manage.py createsuperuser

After using this command the terminal will ask you to enter your username and password. Fill in the following details and press enter. Now your superuser is created successfully.

Now, open your admin panel and fill in the required details.

So, our model is successfully added in the Django admin.

But this is not the way we want our users to use it. We want our users to submit contacts through views. So, let's do that.