Django admin panel model registration

At the end of this project, you have successfully created a portfolio blog. You can now add some data in the admin panel. For that, you need to register the models in the admin.py file. Add following code for blog>admin.py and contactus>admin.py file.

In blog > admin.py file type,


from django.contrib import admin
from .models import (
    PortfolioAboutPage,
    ProjectCompleted,
    SliderImages,
    Blog
)

# Register your models here.
admin.site.register(ProjectCompleted)
admin.site.register(PortfolioAboutPage)
admin.site.register(SliderImages)
admin.site.register(Blog)

For contactus > admin.py

from django.contrib import admin
from .models import Contact
# Register your models here.
admin.site.register(Contact)

To add data first create a super user. To do that

Type in terminal.


python manage.py createsuperuser

This will ask for username and pass you can give a any username and pass, it will ask in terminal when you type hit enter to go to next. 

You will see something like this

And then go to 

http://localhost:8000/admin/ 

Once you are there it will ask for username and pass, type the username and pass you just created.

You will see an interface like, 

After you login you see something like

Leave a Reply

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