Customizing the Django Panel: A Step-By-Step Guide

DDD
Release: 2024-09-19 06:30:03
Original
412 people have browsed it

In this guide I'll walk you through how to modify and extend Django default admin panel/interface, making it more user-friendly.

1. Set up the Project:

Start by creating a brand new project and app in Django

django-admin startproject myprojectname
cd myprojectname
python manage.py startapp developerscommunity
Copy after login

** Note**
Do not forgot to add your app ti the INSTALLED_APPS in settings.py

2. Run migrations:

python manage.py makemigrations
python manage.py migrate
Copy after login

3. Resgister Models in Admin Panel:

 Register of models is compulsory to see it in django admin 
 interface

  from django.contrib import admin
  from .models import DevCommunity

 admin.site.register(DevCommunity)
Copy after login

Above Steps will lead you to Django Admin Panel Now comes the customization part

4. Customize the Admin Panel:

class CustomAdminSite(admin.AdminSite):

will appear at the top-left corner

site_header = "Dev Admin"

will show in the browser tab

site_title = Developer Admin Portal

will be displayed on the admin home page.

index_title = "Welcome to Developer Community"

custom_admin_site = CustomAdminSite(name="dev_admin")

  #All code at one place
  class CustomAdminSite(admin.AdminSite):
     site_header = "Dev  Admin"
     site_title = Developer Admin Portal
     index_title = "Welcome to Developer Community"

  custom_admin_site = CustomAdminSite(name="dev_admin")
Copy after login

5. To register:

  #Finally register
  custom_admin_site.register(DevCommunity)
Copy after login

Customizing the Django Panel: A Step-By-Step Guide

The above is the detailed content of Customizing the Django Panel: A Step-By-Step Guide. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!