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.