This note uses Django-1.8.6, other versions do not
After the Django project is created, it is necessary to configure the parameters first, commonly used configurations include: database configuration , template configuration , static file configuration ,session configuration, etc.
1, database configuration. Locate the Databases field in settings.py to configure the following:
1DATABASES = {2 'default': {3 'ENGINE':'Django.db.backends.mysql',#the MySQL database is configured here4 'HOST':'Database server IP',5 'PORT': 3306,#database port, MySQL default port is 33066 'NAME':'Database name',7 'USER':'Database user name',8 'PASSWORD':'user-corresponding password',9 }Ten}
2. A template has been configured by default in Django-1.8.6, as follows. If you need to modify the template path, simply modify the dirs line
1TEMPLATES = [2 {3 'Backend':'django.template.backends.django.DjangoTemplates',4 'DIRS': [Os.path.join (Base_dir, 'templates' )] #to configure multiple paths, you can use commas to separate them5 ,6 'App_dirs': True,7 'OPTIONS': {8 'context_processors': [9 'Django.template.context_processors.debug',Ten 'django.template.context_processors.request', One 'Django.contrib.auth.context_processors.auth', A 'django.contrib.messages.context_processors.messages', - ], - }, the }, -]
3, configure the static file path, where the static file is configured in the project root directory, the Staticfiles_dirs field is not the default, you need to add
1 staticfiles_dirs = [2 os.path.join (base_dir,'static' ) )3 ]
4. Session Timeout setting
1 session_expire_at_browser_close = True # SESSION Timeout When browser is off 2 3 session_cookie_age = 60*30 # set SESSION time-out, unit is seconds
Django parameter settings