Django getting started case development (I), django case

Source: Internet
Author: User

Django getting started case development (I), django case

Django is a heavyweight web development framework that provides many internal plug-ins for us to use. Here, we do not describe Django to directly enter the development process.

The Django entry-level case consists of two parts: 1. Development Environment configuration; 2. Business Requirement Analysis.

Part 1: Development Environment Configuration

Development Environment blueprint ---->

 

(1). setting. py Configuration:

Configure database connection:

DATABASES = {
'Default ':{
'Engine': 'django. db. backends. mysql', # mysql driver
'Name': 'focal ', # Database NAME
'Host': 'localhost', # The Connection address can also be 127.0.0.1.
'User': 'focusbi ', # database username
'Password': 'focal ', # Database PASSWORD
'Port': '123', # mysql Default PORT. If you have modified the PORT, you must write it as the PORT number you have modified.
}
}

Configure static folders:

STATIC_URL = '/static /'
STATICFILES_DIRS = [
OS. path. join (BASE_DIR, 'static ')
]
MEDIA_ROOT = OS. path. join (BASE_DIR, 'static/media ')

Comment out # 'django. middleware. csrf. CsrfViewMiddleware 'in MIDDLEWARE_CLASSES because it will prevent POST submission.

 

 

(2) create an application:

  

After the application is created, add the application name in setting. py. Add pymysqldb to the _ init _. py file in the projectBook folder.

  

 

(3) create models. py urls. py views. py

Here, the models. py views. py framework is automatically created when an application is created. Now you only need to create urls. py in the application, and then register the urls

 

 

(4) create static resource files and html folders

This is easy to follow the graph.

 

Here we will share the development environment setup in the previous four steps, and the business process to be sorted in the future.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  

 

Related Article

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.