Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of Django Admin?

Shulou Source: shulou.com Published: 2022-06-02 05:35:34 10月16日 Update

This article mainly explains "what is the use of Django Admin". Friends who are interested may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "what is the use of Django Admin"?

Create an administrator user

Enter python manage.py createsuperuser on the command line

Follow the prompts to enter the user name, email address, password

Browser input http://127.0.0.1:8000/admin

Enter the background management login interface

Change the admin background language

Find settings.py 's MIDDLEWARE (middleware)

Add 'django.middleware.locale.LocaleMiddleware'

Note: do not disrupt the order

MIDDLEWARE = ['django.middleware.security.SecurityMiddleware',' django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware',' django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',' django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',' django.middleware.clickjacking.XFrameOptionsMiddleware',]

Refresh the interface

Apply backend management model registration

Admin.py under the application folder

From django.contrib import admin# Register your models here.from .models import studentsadmin.site.register (students)

Add, delete and correct

Functional perfection sets the model name

Modify the model

From django.db import models# Create your models here.class students (models.Model): no=models.CharField ('student number', max_length=8,unique=True,primary_key=True) name=models.CharField ('name', max_length=12) sex=models.CharField ('gender', max_length=2) address=models.CharField ('address' Max_length=40) # set the information displayed in the background def _ _ str__ (self): return str (self.name) class Meta: verbose_name=' student information 'verbose_name_plural=' student information'

After synchronizing the database

At the beginning of the English field name becomes the name of the setting

Set the displayed fields

Admin.py

Set up list_display

From django.contrib import admin# Register your models here.from .models import studentsclass st (admin.ModelAdmin): list_display= ('name','sex','address',) admin.site.register (students,st)

Name of the backend management system

In admin.py

Admin.site.site_title=' background 'admin.site.site_header=' Student background Management system'

The title of the web page and the title in the content become the set content.

At this point, I believe you have a deeper understanding of "what is the use of Django Admin?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Background management method content usage information student model input name address field user interface management system system learning application practical deeper Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Redmi Shulou Tech Info Shulou Information Shulou Technology