Call the Django admin documentation docs!

Source: Internet
Author: User
Tags myadmin

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:

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('')),    # 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/(.*)',,)
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:
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
```` at the URL ``/admin/`` ::
    from django.conf.urls.defaults import *
    from django.contrib import admin
    urlpatterns = patterns('',
Above we used ``admin.autodiscover()`` to automatically load the
``INSTALLED_APPS`` modules.
In this example, we register the ``AdminSite`` instance
``myproject.admin.admin_site`` at the URL ``/myadmin/`` ::
    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 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:
The texture cannot be pasted. paste a link. Check it for yourself.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.