2.4.1. Django uses the built-in admin to Manage Users

Source: Internet
Author: User

After opening the session, next:

First, in settings. py, open the auth, contenttypes, sessions, and Admin applications. The red part of the code is as follows:

Installed_apps = (

'Django. contrib. auth ',

'Django. contrib. contenttypes ',

'Django. contrib. session ',

# 'Django. contrib. Sites ',

# 'Django. contrib. Messages ',

# 'Django. contrib. staticfiles ',

# Uncomment the next line to enable the admin:

'Django. contrib. admin ',

# Uncomment the next line to enable admin documentation:

# 'Django. contrib. admindocs ',

)

Ü Add the following content in the header when modifying URLs. py:

From Django. contrib import Admin

Admin. autodiscover ()

Then add the urlpattern of admin: (R' ^ admin/', include (Admin. Site. URLs). For more information, see section 2.3.1.

Remember the previous Python manage. py syncdb? Run the command to create the admin and Auth database tables (the premise is settings. in py, data_base must be correctly configured.) in this process, you will be asked to create an administrator account. If no Administrator account is created, you can manually run $ Python manage. create py createsuperuser again:

The procedure for creating a database table is as follows:

Creating tables...

Creating table auth_permission

Creating table auth_group_permissions

Creating table auth_group

Creating table auth_user_user_permissions

Creating table auth_user_groups

Creating table auth_user

Creating table auth_message

Then you can access

$ Python manage. py MAID: 8000

Http: // 10.1.1.159: 8000/admin/

You can see the built-in login management interface of Django. Enter the username and password of the Administrator you just created to add a user and change the permissions. If you are an english user, you only need to modify settings. in py, you can see the Chinese management interface. For example:

 

 

More can refer to: https://docs.djangoproject.com/en/1.5/ref/contrib/admin/

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.