Home >>Django Tutorial >Django Admin Interface

Django Admin Interface

Django Admin Interface

Django provides a ready-to-use admin interface which can be used to perform CRUD operations on the models and administrative activities. Django automatically generates admin UI based on our project models where the user can manage the content of the application.

To have it working we need to make sure that some modules are imported in the INSTALLED_APPS and MIDDLEWARE_CLASSES tuples of the myproject/settings.py file.

For INSTALLED_APPS make sure you have −


INSTALLED_APPS = (
   'django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'myapp',
)

For MIDDLEWARE_CLASSES −


MIDDLEWARE_CLASSES = (
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

Create an Admin User

$ python3 managen.py createsuperuser  

Now we can start the development server and access admin login.

$ python3 manage.py runserver  

Now we have to provide the created username and password and login.

After login successfully, it will show us the Django Admin Dashboard. Here, we can administrate Django groups and users, and all registered models in our app.

This interface gives us the ability to do the "CRUD" (Create, Read, Update, Delete) operations on our models.


No Sidebar ads