Django uses the project creation process for the database

Source: Internet
Author: User

1. Create a project f:\>django-admin.py Startproject csvt03

2. Switch directory F:\>CD csvt03

3. Create a project f:\csvt03>django-admin.py Startapp blog

4. configuration file sittings.py Add app let framework find

sittings.py metabase Parameters engine: Database type name: Database name (database to create) host and port Use default can not fill

5. Create the class employee, which is equivalent to creating the table employee in the CSVT database configured above (its parent class is models. Model),

Add Class Property name, which is the equivalent of adding a name field to the employee table, and specifying the maximum length of the field after the = number

6. Execute the Database synchronization command Python manage.py syncdb, at which point the Employee table and the Name field we added above will be created into the database. Table name is Blog_employee

The database Synchronization command checks each project's database file for modifications and does not perform any action if no modifications are performed.

7. Display the database contents on the page, configure urls.py to create the access path, and specify the method to receive the access path

8. urls.py Specifies that the index method in views.py receives the URL request, and then adds the implementation of the method to the views.py file (which is empty) . The Employee.objects.all () method returns all the contents of the employee table, the method

9. The index method in views.py returns a file for the request index.html, the file must be created by itself, the file and the default location is templates directory, the directory is also created by itself, the index.html code is as follows, the inside of the tag receives the value of the function passed in.

Django uses the project creation process for the database

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.