周末没事在家捣腾Django ,使用的最新版本1.1, 启用'django.contrib.admin'后login到admin显示"You don't have permission to edit anything", 查了下文档[url]http://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf[/url],发现admin.autodiscover()这行注释没去掉,再试就可以编辑了。
Above we used admin.autodiscover() to automatically load the INSTALLED_APPS admin.py modules.
[url=http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-objects]ModelAdmin objects [/url]
class ModelAdmin
The ModelAdmin class is the representation of a model in the admin interface. These are stored in a file named admin.py in your application. Let’s take a look at a very simple example of the ModelAdmin:
# urls.py
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
('^admin/', include(admin.site.urls)),
)
Above we used admin.autodiscover() to automatically load the INSTALLED_APPS admin.py modules.
[url=http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-objects]ModelAdmin objects [/url]
class ModelAdmin
The ModelAdmin class is the representation of a model in the admin interface. These are stored in a file named admin.py in your application. Let’s take a look at a very simple example of the ModelAdmin:
from django.contrib import admin
from myproject.myapp.models import Author
class AuthorAdmin(admin.ModelAdmin):
pass
admin.site.register(Author, AuthorAdmin)