DJANGO ADMIN Default CRUD Operations in Django Prepared by Rachit Joshi 1. Introduction Django Admin is a powerful, built - in administrative interface provided by the Django web framework. It automatically generates a web - based dashboard for managing application data and models. The interface is primarily intended for internal use by trusted users and administrators. Django reads metadata from application models and uses it to generate an interface through which authorized users can perform CRUD operations: Create, Read, Update, and Delete. 2. Key Features of Django Admin • Auto - generated interface based on Django model metadata. • CRUD operations for creating, reading, updating, and deleting model records. • Model - centered data management. • Internal data - management interface for trusted users. • Customization through ModelAdmin, search, filters, custom actions, and templates. • Built - in permissions to control access to models and operations. 3. Preparing the Django Admin The Django admin application is included by default in a standard Django project. Before creating a superuser, apply the project's database migrations. python manage.py migrate 4. Creating a Superuser A superuser can access the Django Admin interface with full permissions. Create one using the following command: python manage.py createsuperuser Django prompts for a username, email address, and password. Use a strong password, especially for any environment exposed beyond local development. 5. Registering an Application The application that contains your models must be included in INSTALLED_APPS. For example, a project may include an application named courses: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'courses', ] 6. Creating Models Django Admin works with registered models. The following example defines Instructor and Course models: from django.db import models class Instructor(models.Model): name = models.CharField(max_length=100) email = models.EmailField(unique=True) experience = models.IntegerField() def __str__(self): return self.name class Course(models.Model): title = models.CharField(max_length=200) description = models.TextField() instructor = models.ForeignKey(Instructor, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title 7. Registering Models in admin.py Models can be registered with Django Admin using admin.site.register() or the @admin.register() decorator. ModelAdmin can be used to customize the way a model is displayed. from django.contrib import admin from .models import Course, Instructor @admin.register(Course) class CourseAdmin(admin.ModelAdmin): list_display = ('title', 'instructor', 'created_at') search_fields = ('title',) list_filter = ('instructor',) @admin.register(Instructor) class InstructorAdmin(admin.ModelAdmin): list_display = ('name', 'email', 'experience') search_fields = ('name',) 8. Running the Development Server Start the Django development server with: python manage.py runserver After the server starts, open the Django Admin URL in a browser and sign in using the credentials created for the authorized user. 9. Performing CRUD Operations Operation Meaning Django Admin Example Create Add a new record Click Add and enter model data Read View existing records Open a registered model Update Edit a record Open a record and change its fields Delete Remove a record Open a record and use the delete option 10. Superuser vs Staff User User Type Access Purpose Superuser All models and permissions Full administrative access Staff User Only explicitly granted permissions Controlled administrative access 11. ModelAdmin and AdminSite ModelAdmin controls how an individual model is presented and managed within the admin site. AdminSite represents the overall admin site and can be used for broader configuration such as branding and URL configuration. 12. Frequently Asked Questions What is Django Admin? It is Django's built - in browser - based administration interface for managing model data. Can Django Admin perform CRUD operations? Yes. Authorized users can create, read, update, and delete model records. Do I need a superuser? A superuser is one way to obtain full administrative access; staff users can be given limited permissions. Can Django Admin be customized? Yes. ModelAdmin provides options such as list displays, search fields, filters, actions, and template customization. 13. Conclusion Django Admin provides a convenient way to manage application data without building a separate administration interface from scratch. By registering models and configuring ModelAdmin, developers can provide authorized users with a structured interface for CRUD operations, searching, filtering, and data management