开发: July 2008 Archives

今天从django的svn拉出一份出来写点东东,写好了models,runserver查看admin的时候却出现了如下提示
You don't have permission to edit anything
翻了一下文档,发现已经0.97的时候变化了很多的东东。最后说明是要这样写。
urls.py里写入
from django.contrib import admin
admin.autodiscover()

settings.py中的INSTALLED_APPS部分加入

 INSTALLED_APPS = (
    'django.contrib.admin')

models.py的最后要写上

from django.contrib import admin
admin.site.register(MODELNAME)

这样才算是OK。
update: django 1.0之后的应该把上面这一段放到admin.py里去,而且要把以前写在models.py里的class admin部分也放到admin.py例子如下:

from django.contrib import admin
from models import Module
class ModuleAdmin(admin.ModelAdmin):
	list_display = ['name','manager','isdpool']
	filter_horizontal = ['host']
admin.site.register(Module,ModuleAdmin)

About this Archive

This page is a archive of entries in the 开发 category from July 2008.

开发: March 2008 is the previous archive.

Find recent content on the main index or look in the archives to find all content.

July 2008: Monthly Archives

Pages

Powered by Movable Type 4.21-en