Render a model in Django Admin Interface
To render a model in Django admin, we need to modify app/admin.py. Go to admin.py in geeks_site_app and enter the following code. Import the corresponding model from models.py and register it to the admin interface.
Python3
from django.contrib import admin from .models import GeeksModel # Register your models here. admin.site.register(GeeksModel,) |
Now let’s create a superuser for our project that can have access to the admin area of our site. To create a super user type the below command –
python manage.py createsuperuser
Now go to http://127.0.0.1:8000/admin on the browser to access the admin interface panel.
Give the username and password created for superuser and then the admin dashboard will open and there we will be able to see our Geeks models that we just created.
Note: For more information refer to Render Model in Django Admin Interface.
Now let’s see how to enter data using the admin dashboard. Now clicking on the Geeks Model we will see something like this –
We can click on the Add Geeks Model button on the right top corner and then we will be able to see the fields for adding data. See the below image –
After adding the required data and the image field we will see something like this on our admin dashboard –
You can also see the media folder in your code editor –
Python Web Development With Django
Python Django is a web framework that allows to quickly create efficient web pages. Django is also called batteries included framework because it provides built-in features such as Django Admin Interface, default database – SQLite3, etc. When you’re building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc. Django gives you ready-made components to use.