I mean, after logging on to the admin background management of Django, you can refer to admindocs provided by Django.
How can this problem be solved? You can refer to a Django official site of a tutorial 2: http://docs.djangoproject.com/en/dev/intro/tutorial02/
There is a part of how to activate background management.
from django.conf.urls.defaults import *# Uncomment the next two lines to enable the admin:from django.contrib import adminadmin.autodiscover()urlpatterns = patterns('', # Example: # (r'^mysite/', include('mysite.foo.urls')), # Uncomment the admin/doc line below and add 'django.contrib.admindocs' # to INSTALLED_APPS to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/(.*)', admin.site.root),)
Note that the code above contains # (R' ^ admin/doc/', include ('django. contrib. admindocs. URLs '), is commented out, you can delete #, so that you can open the URL, at the same time in settings. add an app to installed_apps in Py, that is, 'django. contrib. admindocs'
After completing the above, we can access some very useful docs after logging on to the admin background.
Note the following issues:
1, need the support of docutils this module. Is: http://docutils.sf.net/
2. be sure to note (R' ^ admin/doc/', include ('django. contrib. admindocs. URLs '), place the location (or order), note that you must place(R '^ admin/(. *)', admin. Site. root). Put the code above the line below, it will cause a 404 error, that is, the docs cannot be found.
The specific reason is: (R' ^ admin /(. *) ', admin. site. root), R' ^ admin /(. (. *) The meaning of the regular expression is that it matches any thing under any admin/, so(R' ^ admin/doc/', include ('django. contrib. admindocs. URLs '), if it is placed under it, it will be admin /(. *) to be ignored. I did not solve the problem for several days because I put it below, and I couldn't find the reason for it. Later I took a look at the tutorial and carefully compared it to find out that this was the case.
If you delete (. *), your admin background will not be used and an error will be reported, so docs will be useless.
Is it because the URL of docs is placed under admin (. *) and admindocs cannot be used forever? That's certainly not. I have already tried it out. Just change the regular URL of R' ^ admin/DOC ', for example, R' ^ admindoc', and you can use admindocs, in general, its URL should not be placed behind 'admin/', because admin (. *) It matches everything on the top. I have already mentioned this.
Why does admin (. *) match everything? There is a Docs directory in the downloaded Django package. There is an admin.txt under the subdirectory ref/contrib/, which contains the following:
In this example, we register the default ``AdminSite`` instance
``django.contrib.admin.site`` at the URL ``/admin/`` ::
# urls.py
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
('^admin/(.*)', admin.site.root),
)
Above we used ``admin.autodiscover()`` to automatically load the
``INSTALLED_APPS`` admin.py modules.
In this example, we register the ``AdminSite`` instance
``myproject.admin.admin_site`` at the URL ``/myadmin/`` ::
# urls.py
from django.conf.urls.defaults import *
from myproject.admin import admin_site
urlpatterns = patterns('',
('^myadmin/(.*)', admin_site.root),
)
There is really no need to use autodiscover when using your own ``AdminSite``
instance since you will likely be importing all the per-app admin.py modules
in your ``myproject.admin`` module.
Note that the regular expression in the URLpattern *must* group everything in
the URL that comes after the URL root -- hence the ``(.*)`` in these examples.
Pay attention to the bold part of the last section above, and you will understand it.
Well, let's talk a little bit about it. Let's see what I have done with admindocs:
http://p.blog.csdn.net/images/p_blog_csdn_net/huyoo/EntryImages/20080926/admindocs.jpg
The texture cannot be pasted. paste a link. Check it for yourself.