django笔记三之admin的管理
设置自动admin应用
vim todos/settings.py
INSTALLED_APPS = (
'django.contrib.admin', 新版本已经默认打开了
'django.contrib.auth',
)
[root@desktop1 blog]# cat models.py
from django.db import models
from django.contrib import admin
importance_choices=(
('A','very inportance'),
('B','importance'),
('C','Medium'),
('D','Unimportant'),
)
class Todo(models.Model):
title=models.CharField(max_length=200)
description=models.TextField()
importance=models.CharField(max_length=1,choices=importance_choices)
admin.site.register(Todo)
查看页面:
点击add todo会发现一下界面::