django admin的变化

| No Comments | No TrackBacks
今天从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)

No TrackBacks

TrackBack URL: http://mt.khsing.net/cgi-bin/mt-tb.cgi/26

Leave a comment

About this Entry

This page contains a single entry by Guixing published on July 21, 2008 4:50 PM.

macport操作 was the previous entry in this blog.

FreeBSD导致同事工作效率低下? is the next entry in this blog.

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