A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python-django-admin-interface/ below:

Django Admin Interface - Python

Django Admin Interface - Python

Last Updated : 11 Jul, 2025

Prerequisites:

The Django Admin Interface is one of the most powerful features of the Django framework. It provides a ready-to-use interface for managing project data through models, allowing developers and site administrators to perform Create, Read, Update, and Delete (CRUD) operations with ease.

When we start a new Django project, Django automatically includes a built-in admin app (django.contrib.admin). This interface is a web-based dashboard that lets us manage the database content of your registered models.

It offers:

This article explores how the Django Admin Interface works, how to access it, and how to customize it for your application.

Accessing the Admin Panel

Django provides a built-in admin interface accessible via your browser. To access it, first ensure your development server is running, to run the development server, use this command:

python manage.py runserver

Now, to access the admin panel open your browser and navigate to:

http://127.0.0.1:8000/admin/

You’ll be prompted to enter a username and password.

There are basically two ways to access the Django admin panel:

1. Superuser 2. Staff User with Permissions

Example of creating a staff user (in a script or shell):

from django.contrib.auth.models import User
user = User.objects.create_user(username='editor', password='pass123')
user.is_staff = True
user.save()

Then use the Django Admin to assign model-specific permissions via the Users section.

Accessing the Admin with Superuser

The admin app(django.contrib.admin) is enabled by default and already added to the INSTALLED_APPS list present in the settings.py file. If you don’t have a user yet, the quickest way to log in is by creating a superuser.

Run the following command in terminal:

python manage.py createsuperuser

Provide the required information:

Then start the development server:

python manage.py runserver

Go to http://127.0.0.1:8000/admin/, log in with your superuser credentials, and you’ll see the Django Admin Dashboard. From here, we can manage all registered models, users, and site data:

After logging in successfully, it shows the interface as shown below: .

Reset Django Admin Password

To reset the superuser password, use the following command:

python manage.py changepassword <username>

Replace <username> with your actual superuser name.

Note: Ensure that the terminal is active in the directory where manage.py is located before running this command.

Changing password of the superuser whose username is Abhishek_Shakya Registering Models in the Admin Panel

By default, only Django’s built-in models appear in the admin panel. To manage our own app models via the admin interface, we need to register them.

Before proceeding further, ensure that the Django project and app is already created, if not then refer to this article to learn to to create and setup a Django project and app.

Creating Django Project
Creating Django App

python manage.py createapp myapp

Step 1: Define a Model in models.py Python
from django.db import models

class FacultyDetails(models.Model):
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)
    department = models.CharField(max_length=50)

    def __str__(self):
        return f"{self.first_name} {self.last_name}"
Step 2: Register the Model in admin.py Python
from django.contrib import admin
from .models import FacultyDetails

admin.site.register(FacultyDetails)
Step 3: Apply Migrations

python manage.py makemigrations
python manage.py migrate

Once registered and migrated, our model will appear on the Django admin dashboard, ready for data manipulation.

Now the admin page will have the model FacultyDetails but make sure the server is up and running.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4