1.vim settings.py inside Open Installed_apps below django.contrib.admin (that is, uncomment)
2.vim urls.py Open the top from django.contrib import admin and Admin.autodiscover () and the following URL (R ' ^admin/', include ( Admin.site.urls)),
3.vim blog/models.py
From django.db import Models
Sex_choice= (#这里定义了一个选择的二元组, the preceding information for the display, followed by a hint
(' F ', ' Famale '),
(' m ', ' Male '),
)
Class User (Models,model):
Name = models. Charfield (max_length=30)
Sex = models. Charfield (max_length=1,choices=sex_choices)
def __unicode__ (self):
Return Self.name
4.python manage.py syncdb# Synchronization database, this synchronization found in addition to Blog_user, but also a django_admin_log, this is our corresponding to the background management of a table
5. At this point we can choose Yes to create a database administrator user, as prompted to enter information
6.python manage.py runserver# Run the development server and use the browser to test access 127.0.0.1:8000/admin/found a login interface, but there is no related blog_user table we created
7.vim blog/admin.py# This file is new
From Django.contrib Import admin
From Blog.models import User
Admin.site.register (User)
8. Re-enter the Web interface to find the Blog_user table appears, and can perform additional operations and so on, but the display is indeed the name of the user object, not intuitive, and then modify models.py
9.vim blog/models.py Add a Unicode method (added, on top)
9.Django admin for Web interface Background Management database