In 开发者_运维知识库DjangoBook, it says that the every books app should have its own admin.py. However, none of my apps have there own separate admin.py as the text suggests. I was just wondering if this is a Django 1.3 thing and if so, where is the admin.py data stored now, if not in a separate admin.py file?
The chapter I'm referring to is here: http://djangobook.com/en/2.0/chapter06/
P.S. I'm not talking about django-admin.py
By default there is no admin.py file created for you when you create a new app, you will need to create your own. Here are the directions on how to create the admin.py file.
http://docs.djangoproject.com/en/1.3/ref/contrib/admin/
Edit: 1.3 is no longer supported, here is a link to 1.8:
https://docs.djangoproject.com/en/1.8/ref/contrib/admin/
You need to create admin.py in new app and edit it with
from django.contrib import admin
In project/urls.py, in my case (mysite/urls.py) specify the url of newapp/admin (polls/admin) like
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',url(r'^admin/', include(admin.site.urls)),)
精彩评论