The Wayback Machine - https://web.archive.org/web/20241006222144/https://www.geeksforgeeks.org/python-django-admin-interface/
Open In App

Python | Django Admin Interface

Last Updated : 21 Aug, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

In this article, we delve into the capabilities and advantages of the Django Admin Interface, exploring how its customizable features and streamlined workflows empower developers to effortlessly administer their projects, from data management to user interactions.

Prerequisites: django-introduction-and-installation | django-introduction-set-2-creating-a-project

Django Admin Interface

When you start a project with Django it also provides a default admin interface that can be used to perform create, read, update, and delete operations on the model directly. It reads a set of data that explains and gives information about data from the model, to provide an instant interface where the user can adjust the contents of the application. This is an in-built module designed to execute admin-related work for the user.

Creating a Superuser in Django Project

The Superuser is the one who can access the Django administration panel and can perform CURD operation on the created models which are shown in the admin panel. The admin app(django.contrib.admin) is enabled by default and already added to the INSTALLED_APPS list present in the settings.py file.

installed_packs

To access this admin interface on browser write ‘/admin/’ at ‘localhost:8000/admin/’ and it shows the output as given below:

Note: we are assuming that you have deployed your project on local server.

login

It prompts for login details, if no login id is created before, then a new superuser can be created by using the command given below:

python manage.py createsuperuser

https://media.geeksforgeeks.org/wp-content/uploads/Screenshot-529.png

Now, access the admin login page after starting the Development Server which can be done by using the command given below.

python manage.py runserver

runserver

Enter username and password, then hit login .

login

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

Django Admin Interface

This is what is called a Django Admin Dashboard where one can add, delete and update data belonging to any registered model.

Reset Django Admin Password

In Django we can reset django admin password but for this this must make sure you already created a superuser already for which we uses `createsuperuser`command . This command allows you to create a new superuser account or update an existing one if you already have one, and after creating the superuser as show in the above article then we can use the `changepassword` command provided with name of the super user with it and it will change the superuserpassword this will reset the django admin password.

Before writing the command make sure that current directory must have manage.py file within it and If not Open the terminal and cd (change directory) into the project folder (the directory with the manage.py file).

Then run the command:

python manage.py changepassword <username>

Replace <username> with the username of the user for whom you want to change the password.

Here’s an example of how you would use the changepassword command in my case the superuser is Abhishek_Shakya so cammad would be like

python manage.py changepassword Abhishek_Shakya
Untitled-1
Changepassword of the superuser

and by this we can reset or update the superuser password

Register Model in Django Admin

After starting your project in django and creating or resetting your django superuser you can now access the django administrator and through django admin panel you can perform CRUD operations on your models but the model you created in your app only shows in the admin panel when you register them in your `admin.py` of the app you created.

after stating the project create an app

python manage.py createapp myapp

Now in the myapp folder we have the file models.py in which we create our model and after creating those model we need to register them in the admin.py file of the myapp folder after that we makemigrations of the model created.

Screenshot-(13)-(3)
register model in django-admin

and the after model creation you have to register the model in django by regestering them into admin.py file of `myapp` folder

first import your model at the top of the admin.py file if the model you are importing is in the same file you can import by

from .models import <model.name>

In this case the model is Faclity_details, so

from .models import Faclity_details

Now we have to register the model in the admin.py file so that it can we visible on the admin panel

admin.site.register<Model.name>

In this case the model is Faclity_details,so

admin.site.register(Faclity_details)
Untitled-3
Register model in admin
python manage.py makemigrations

after that migrate all the migrations

pyhton manage.py migrate

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

Django Admin Interface

Now you are all set to go.



Previous Article
Next Article

Similar Reads

Render Model in Django Admin Interface
Rendering model in admin refers to adding the model to the admin interface so that data can be manipulated easily using admin interface. Django's ORM provides a predefined admin interface that can be used to manipulate data by performing operations such as INSERT, SEARCH, SELECT, CREATE, etc. as in a normal database. To start entering data in your
3 min read
Customize Django Admin Interface
Django admin by default is highly responsive GUI, which offers various features and an overall CRUD application to help developers and users. Moreover, Django admin can be customized to fulfill one's needs such as showing fields on the home page of the table, etc. In this article, we will discuss how to enhance Django-admin Interface. Project struc
3 min read
Disable Admin-Style Browsable Interface of Django REST Framework
Django REST Framework (DRF) is a powerful and flexible toolkit for building Web APIs in Django. One of its features is the browsable API, which provides a user-friendly, web-based interface for interacting with the API. While this can be helpful during development and debugging, it may not be desirable in a production environment for security or pe
3 min read
Django Admin - Redesign and Customization
Often the default Django admin page is great and it is all we need for our projects but sometimes we may want to expand what default admin interface can do. We have a lot of tools in Django to customize it to our own needs and in this article, we'll learn how to customize the admin interface and add multiple features: Let's setup your project, add
4 min read
Securing Django Admin login with OTP (2 Factor Authentication)
Multi factor authentication is one of the most basic principle when adding security for our applications. In this tutorial, we will be adding multi factor authentication using OTP Method. This article is in continuation of Blog CMS Project in Django. Check this out here – Building Blog CMS (Content Management System) with Django Setup 2 Factor Auth
2 min read
How to Show a Many-to-Many Field with "list_display" in Django Admin
In Django, the list_display attribute in the Django Admin interface allows developers to specify which fields to display in the list view of the admin panel. This feature is particularly useful for providing a quick overview of the model instances. However, displaying many-to-many fields in the list_display can be a bit tricky since these fields ca
3 min read
How to Override CSS in Django Admin?
Django's admin interface is a powerful tool for managing application data. It comes with a default styling that may not always fit the visual identity of your project. Customizing the admin interface can help create a more cohesive user experience. In this article, we'll walk you through the process of overriding the CSS in Django's admin panel by
3 min read
Making a Django Admin Field Non-Required Without Custom Form Creation
The Django admin interface is a great tool for managing data in your Django application. Sometimes, you may need to make some fields optional in the admin panel, meaning these fields shouldn't be required when creating or updating records. Typically, this is done by creating a custom form. However, there is a simpler way to achieve this directly in
2 min read
Django Admin - Disable the 'Add' Action for a Specific Model
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It's designed to help developers take applications from concept to completion as swiftly as possible. One of the powerful features of Django is its settings configuration, which allows you to keep various parameters and configurations in a cen
3 min read
How to Override and Extend Basic Django Admin Templates?
The Django admin interface provides a robust way to manage our application's data, offering a user-friendly and efficient design. By default, it gives a clean and functional design that is suitable for most needs. Sometimes we need more customized features to better align with our specific requirements like user-centric experience, custom branding,
10 min read
How to Reset Django Admin Password?
Forgetting or needing to reset the admin password in Django is a common issue that can be resolved in a few easy steps. Django provides several ways to reset the admin password, depending on the situation. In this article, we'll explore multiple methods to help you recover or reset the password for your Django admin account. Reset Password via Djan
2 min read
How to Integrate Flask-Admin and Flask-Login
In order to merge the admin and login pages, we can utilize a short form or any other login method that only requires the username and password. This is known as integrating the admin page and Flask login since it simply redirects users to the admin page when they log in. Let's is how to implement this in this article. Integrate Flask Admin and Fla
8 min read
Adding Tags Using Django-Taggit in Django Project
Django-Taggit is a Django application which is used to add tags to blogs, articles etc. It makes very easy for us to make adding the tags functionality to our django project.Setting up Django Project Installing django-taggit pip install django-taggitADD it to Main Project's settings.py file C/C++ Code INSTALLED_APPS = [ 'django.contrib.admin', 'dja
2 min read
How to customize Django forms using Django Widget Tweaks ?
Django forms are a great feature to create usable forms with just few lines of code. But Django doesn't easily let us edit the form for good designs. Here, we will see one of the ways to customize Django forms, So they will look according to our wish on our HTML page. Basically we will check the methods to include our own custom css, classes, or id
3 min read
Styling Django Forms with django-crispy-forms
Django by default doesn't provide any Django form styling method due to which it takes a lot of effort and precious time to beautifully style a form. django-crispy-forms solves this problem for us. It will let you control the rendering behavior of your Django forms in a very elegant and DRY way. Modules required:django : django installdjango-crispy
1 min read
Integrating Django with Reactjs using Django REST Framework
In this article, we will learn the process of communicating between the Django Backend and React js frontend using the Django REST Framework. For the sake of a better understanding of the concept, we will be building a Simple Task Manager and go through the primary concepts for this type of integration between React js and Django. Reactjs in a nuts
15+ min read
How to Fix Django "ImportError: Cannot Import Name 'six' from 'django.utils'"?
After Django 3.0, django.utils.six was removed. The "ImportError: Cannot Import Name 'six' from 'django.utils'" error occurs because of the dependency issue. This happens because when the project tries to use something that’s no longer available. Don’t worry—it’s easy to fix. We’ll explain why this error happens and give you simple steps to solve i
3 min read
Python-interface module
In object-oriented languages like Python, the interface is a collection of method signatures that should be provided by the implementing class. Implementing an interface is a way of writing an organized code and achieve abstraction. The package zope.interface provides an implementation of "object interfaces" for Python. It is maintained by the Zope
3 min read
Python - Network Interface
Network interface is nothing but interconnection between two hardware equipment or protocol layers in a computer network. A network interface usually has some form of the network address. It is generally a network interface card that does not have any physical existence. It can be implemented in a software interface. It is difficult to keep track o
1 min read
Difference between abstract class and interface in Python
In this article, we are going to see the difference between abstract classes and interface in Python, Below are the points that are discussed in this article: What is an abstract class in Python?What is an interface in Python?Difference between abstract class and interface in PythonWhat is an Abstract class in Python? A blueprint for other classes
4 min read
Command Line Interface Programming in Python
This article discusses how you can create a CLI for your python programs using an example in which we make a basic "text file manager". Let us discuss some basics first. What is a Command Line Interface(CLI)? A command-line interface or command language interpreter (CLI), also known as command-line user interface, console user interface, and charac
7 min read
Create HTML User Interface using Eel in Python
Eel is a Python library for making simple offline HTML/JS GUI apps, with full access to Python capabilities and libraries. Eel hosts a local webserver, then lets you annotate functions in Python so that they can be called from JavaScript, and vice versa. InstallationTo install this module, type the below command in the terminal. pip install eelGett
2 min read
What is an API (Application Programming Interface)
Everyone is in search of the highest-paying job so as to get into it. And, in the list, the web developer has been on the top for years and will remain in the same place due to its demand. If you're the one who's looking to get into it. you must be aware of the most important terms used in it. Out of all the terms, API is yet another term that play
11 min read
Requirements for Jupyter Notebook Interface
Jupyter is an open-source web application that has revolutionized how data scientists, educators, and researchers work with code and data. By allowing users to create and share documents that combine live code, equations, visualizations, and narrative text, Jupyter has become a cornerstone tool in data science and scientific computing. To maximize
7 min read
Python | User groups with Custom permissions in Django
Let's consider a trip booking service, how they work with different plans and packages. There is a list of product which subscriber gets on subscribing to different packages, provided by the company. Generally, the idea they follow is the level-wise distribution of different products. Let's see the different packages available on tour booking servi
4 min read
Python Django | Google authentication and Fetching mails from scratch
Google Authentication and Fetching mails from scratch mean without using any module which has already set up this authentication process. We'll be using Google API python client and oauth2client which is provided by Google. Sometimes, it really hard to implement this Google authentication with these libraries as there was no proper documentation av
12 min read
Intermediate fields in Django | Python
Prerequisite: Django models, Relational fields in DjangoIn Django, a many-to-many relationship exists between two models A and B, when one instance of A is related to multiple instances of B, and vice versa. For example - In a shop management system, an Item and a Customer share a many-to-many relationship, as one customer can buy multiple items, a
2 min read
Python | Django News App
Django is a high-level framework which is written in Python which allows us to create server-side web applications. In this article, we will see how to create a News application using Django. We will be using News Api and fetch all the headline news from the api. Read more about the api here news api.Do the Following steps in command prompt or term
2 min read
Django Migrations | Python
Prerequisite: Django Models No such table? - The class defined in product/models.py is the mere idea of what our database is going to look like but it didn't create any table in the database. We can assume class Phone as conceptual schema. Before the creation of any table, if we try to access the table before creation, it will throw an error like t
2 min read
Python | Relational fields in Django models
Prerequisite: Django models Django models represent real-world entities, and it is rarely the case that real-world entities are entirely independent of each other. Hence Django supports relational databases and allows us to establish relations between different models. There are three types of relational fields which Django supports: many-to-one, m
4 min read
Article Tags :
Practice Tags :