You don't have permission to edit anything

xiaoxiao2022-06-11  35

周末没事在家捣腾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()这行注释没去掉,再试就可以编辑了。 # urls.pyfrom django.conf.urls.defaults import *from django.contrib import adminadmin.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 adminfrom myproject.myapp.models import Authorclass AuthorAdmin(admin.ModelAdmin): passadmin.site.register(Author, AuthorAdmin)
转载请注明原文地址: https://www.6miu.com/read-4931736.html

最新回复(0)