Development of Python Django program under Linux (Set admin Manager module)

Source: Internet
Author: User

1. New projects and projects under the app

Django-admin Startproject csvt03
Django-admin Startapp App1


2. Modify the settings.py file

Set the default installation app

Installed_apps = (    'Django.contrib.auth',    'Django.contrib.contenttypes',    'django.contrib.sessions',    'django.contrib.sites',    'django.contrib.messages',    'Django.contrib.staticfiles',    'App1',    #uncomment the next line to enable the admin:    'Django.contrib.admin',    #uncomment the next line to enable admin documentation:    #' Django.contrib.admindocs ',)

Set the database to Sqlite3

DATABASES = {    'default': {        'ENGINE':'Django.db.backends.sqlite3',#Add ' postgresql_psycopg2 ', ' PostgreSQL ', ' MySQL ', ' sqlite3 ' or ' Oracle '.        'NAME':'csvt03.db',#Or Path to database file if using Sqlite3.        'USER':"',#Not used with sqlite3.        'PASSWORD':"',#Not used with sqlite3.        'HOST':"',#Set to empty string for localhost. Not used with Sqlite3.        'PORT':"',#Set to empty string for default. Not used with Sqlite3.    }}

3. Create a new database table mapping in the models.py file

sex_choices=(('F','Famale'),('m','male'))classUser (models. Model): Name= Models. Charfield (max_length=30) Sex=models. Charfield (max_length=1,choices=sex_choices)def __unicode__(self):returnSelf.name

4. Edit the urls.py file

 fromDjango.conf.urls.defaultsImportpatterns, include, url#uncomment the next lines to enable the admin: fromDjango.contribImportadminadmin.autodiscover () urlpatterns= Patterns ("',    #Examples:    #URL (r ' ^$ ', ' csvt03.views.home ', name= ' home '),    #URL (r ' ^csvt03/', include (' Csvt03.foo.urls ')),    #Uncomment the Admin/doc line below to enable admin documentation:    #URL (r ' ^admin/doc/', include (' Django.contrib.admindocs.urls ')),    #uncomment the next line to enable the admin:URL (r'^admin/', include (Admin.site.urls)),)


5. Generate Data files

Python manage.py syncdb
Creating Tables ... Creating table auth_permissioncreating table auth_group_permissionscreating table auth_groupcreating table Auth_user_ user_permissionscreating table auth_user_groupscreating table auth_usercreating table auth_messagecreating table django_content_typecreating table django_sessioncreating table django_sitecreating table App1_useryou just installed The Django'S auth system, which meansyou don't have anysuperusers defined. Would to create one now? (Yes/No): Noinstalling custom SQL ... Installing indexes ... No fixtures found.

6. View the Sqlite3 database file after the build

Sqlite3 csvt03.db

Development of Python Django program under Linux (Set admin Manager module)

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.