django-admin Admin

# Django-admin Admin


The establishment of super user privileges

python3 manage.py createsuperuser


Admin login Address:
- <http://127.0.0.1:8000/admin>

 

 

## custom background display a list of
Table 1. Register the background to be displayed

Application in the app file admin.py

from django.contrib import admin

from .models import *
admin.site.register(Book)


2. Select the background to be displayed content is not set, the background display object directly

Book_namager class (models.Model):
list_display = [ 'ID', 'title', 'Pub', '. price'] # background displayed list select fields
list_display_links = [ 'title'] # hyperlinks can be provided to a specific content field
list_filter = [ 'pub'] # set filters, packet format
search_fields = [ 'title'] # fuzzy search field may be provided
list_editable = [ 'price'] # set fields in the list can be edited directly

admin.site.register (Book, Book_namager) # binding table / table manager; and registration


3. Modify the background display

class Book(models.Model):
title = CharField(....)

Meta - class:
named db_table, = 'Book' # within the model used by the database table name. (Required immediately after setting the synchronization database update manage.py makemigrations to python3 / the migrate)
the verbose_name = 'book' # model name (odd) in the background, for displaying / admin management interface
verbose_name_plural = verbose_name # plural form of the object name (s), for displaying / admin management interface

 

Guess you like

Origin www.cnblogs.com/chenlulu1122/p/11921577.html