porject相关
 
settings.py
 
INSTALLED_APPS = (
         'django.contrib.auth',
         'django.contrib.contenttypes',
         'django.contrib.sessions',
         'django.contrib.sites',
   'django.contrib.admin',
   'mypyblog.polls',
)
 
 
urls.py
from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns( '',
        # Example:
        # (r '^mypyblog/', include('mypyblog.foo.urls')),

        # Uncomment the admin/doc line below and add 'django.contrib.admindocs'    
        # to INSTALLED_APPS to enable admin documentation:
        # (r '^admin/doc/', include('django.contrib.admindocs.urls')),

        # Uncomment the next line to enable the admin:

  (r '^admin/(.*)', admin.site.root),    
)
 
 
 
app相关
 
建立app之后 添加models
# -*- coding: utf-8 -*-
from django.db import models

# Create your models here.

class Topic(models.Model):
        title = models.CharField(max_length=100)
        content = models.CharField(max_length=50)
        
class Admin(models.Model):
        username = models.CharField(max_length=10)
        password = models.CharField(max_length=16)
 
ORM模型正确性检验
python manage.py validate
查看数据库结构
python manage.py sql polls
同步数据库
python manage.py syncdb
 
 
在app下建立一个admin.py


from django.contrib import admin
from mypyblog.polls.models import Topic, Admin
admin.site.register(Topic)
admin.site.register(Admin)
 
启动测试服务器
python manage.py runserver
 
django admin扩展 相关备忘录_第1张图片