Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of Django Admin?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report