Write the first Django app, part fourth-the admin function of the initial Django

Source: Internet
Author: User

Enable Administrator features

The Django Administrator feature is not enabled by default-this is an optional option. To enable administrator functionality for your program, you need to do these three things:

1. Add "Django.contrib.admin" to the Installed_apps setting.

2. Run Python manage.py syncdb. When you add a new application to Installed_apps, the database table needs to be manually updated.

3. Edit file mysite/urls.py, uncomment "uncomment the next two lines ..." The line comments below. This file is a URL map.

Finally, your urls.py file should look like the following:

from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.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),
)

Start the development server

Let's start the development server and browse the admin page.

Python manage.py runserver

Now, open the browser and enter the "/admin/" in your local domain--htt://127.0.0.1:8000/admin/, for example. You will see the admin login interface:

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: info-contact@alibabacloud.com 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.