Preparation [plain] service mysqld start create database web10 default character set utf8; django-admin.py startproject web10 django-admin.py startapp blog admin. py create settings configure [python] DATABASES = {'default': {'Engine ': 'django. db. backends. mysql ', 'name': 'web10', 'user': 'root', 'Password': '', 'host':'', 'Port ': '', }} TIME_ZONE = 'Asia/Shanghai' using age_code = 'zh-cn' MEDIA_ROOT = '. /upload/'# media files In this folder, the url path of MEDIA_URL = '/mytes/' # media_root ing INSTALLED_APPS = ('django. contrib. auth ', 'django. contrib. contenttypes ', 'django. contrib. sessions ', 'django. contrib. sites ', 'django. contrib. messages ', 'django. contrib. staticfiles ', 'blog', 'django. contrib. admin ',) models configuration [python] # coding: utf8 from django. db import models from django. contrib import admin sex_choices = ('M', 'male'), ('F', 'fema Le ') class Emp (models. model): name = models. charField (verbose_name = u'name', max_length = 20) sex = models. charField (choices = sex_choices, max_length = 1, verbose_name = u 'gene') birthday = models. dateField () headImg = models. fileField (upload_to = '. /headimg/') # A field is added here. synchronization is ineffective and it is troublesome to go in, so you can delete and recreate it. Class Meta: ordering = ['name'] # internal class EmpAdmin (admin. modelAdmin): # This class is only used to modify the Emp class. Therefore, when registering the class, pay attention to sticking it to a piece of list_display = ['name', 'sex ', 'birthday'] search_fields = ['name', 'sex'] list_filter = ['birthday'] class New (models. model): title = models. charField (max_length = 100, verbose_name = u'title') content = models. textField (verbose_name = u'news') def _ unicode _ (self): return self. title uls configuration [python] from django. conf. Urls. defaults import patterns, include, url from django. contrib import admin. autodiscover () urlpatterns = patterns ('', url (R' ^ admin/', include (admin. site. urls),) admin. py registers [python] from django. contrib import admin from blog. models import Emp, EmpAdmin, New admin. site. register (Emp, EmpAdmin) # Here, Emp is registered with EmpAdmin, while New is registered separately, because EmpAdmin modifies Emp. Admin. site. register (New) writes data to the database. After the server runs [plain] python manage. py syncdb python manage. py runserver, you can go to the management interface to perform operations. This project adds Chinese processing, sorting processing, various field processing, built-in class processing, modifier class processing, and query processing to the previous project.