Python Learning---Django's new project Settings template

Source: Internet
Author: User
Tags sessions

The template can be completely replaced with a partial code after the new project is created.

Create a app01 python startapp app01

Create a static subdirectory

settings.py

"" "Django Settings for User_manager project. Generated by ' Django-admin startproject ' using Django 2.0.1.For more information on the this file, Seehttps://docs.djangoproje Ct.com/en/2.0/topics/settings/for the full list of settings and their values, seehttps://docs.djangoproject.com/en/2.0/ ref/settings/"" "Import os# Build paths inside the project like This:os.path.join (Base_dir, ...) Base_dir = Os.path.dirname (Os.path.dirname (Os.path.abspath (__file__))) # Quick-start Development settings-unsuitable For production# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/# SECURITY warning:keep the Secret key used in production secret! Secret_key = ' (mtzmh6dqyi=f4x6&hb15!gznpuxqm2-2t=xeq$3ga=120qlm& ' # SECURITY Warning:don ' t run with debug Turned on production! DEBUG = Trueallowed_hosts = []# Application Definitioninstalled_apps = [' django.contrib.admin ', ' Django.contrib.aut H ', ' django.contrib.contenttypes ', ' django.contrib.sessions ', ' django.contrib.mesSages ', ' django.contrib.staticfiles ', ' App01 ', # Register App]middleware = [' Django.middleware.security.SecurityMiddl Eware ', ' django.contrib.sessions.middleware.SessionMiddleware ', ' Django.middleware.common.CommonMiddleware ', # ' d Jango.middleware.csrf.CsrfViewMiddleware ', ' django.contrib.auth.middleware.AuthenticationMiddleware ', ' Django.contrib.messages.middleware.MessageMiddleware ', ' Django.middleware.clickjacking.XFrameOptionsMiddleware ' ,]root_urlconf = ' user_manager.urls ' TEMPLATES = [{' Backend ': ' Django.template.backends.django.DjangoTemplates '            , # ' DIRS ': [], ' DIRS ': [Os.path.join (Base_dir, ' templates ')], ' app_dirs ': True, ' OPTIONS ': { ' Context_processors ': [' django.template.context_processors.debug ', ' Django.templ Ate.context_processors.request ', ' Django.contrib.auth.context_processors.auth ', ' Django.cont   Rib.messages.context_processors.messages ',         ],},},]wsgi_application = ' user_manager.wsgi.application ' # database# https://docs.djangoproject.com/e n/2.0/ref/settings/#databasesDATABASES = {' default ': {' ENGINE ': ' Django.db.backends.sqlite3 ', ' NAME ': o S.path.join (Base_dir, ' db.sqlite3 '),}}# Password validation# https://docs.djangoproject.com/en/2.0/ref/settings/# Auth-password-validatorsauth_password_validators = [{' NAME ': ' Django.contrib.auth.password_validation. Userattributesimilarityvalidator ',}, {' NAME ': ' Django.contrib.auth.password_validation. Minimumlengthvalidator ',}, {' NAME ': ' Django.contrib.auth.password_validation. Commonpasswordvalidator ',}, {' NAME ': ' Django.contrib.auth.password_validation. Numericpasswordvalidator ',},]# internationalization# https://docs.djangoproject.com/en/2.0/topics/i18n/LANGUAGE_ CODE = ' en-us ' time_zone = ' UTC ' use_i18n = trueuse_l10n = Trueuse_tz = true# Static files (CSS, JavaScript, Images) # https:Docs.djangoproject.com/en/2.0/howto/static-files/static_url = '/static/' Template_dirs = (Os.path.join (BASE_DIR, ' Templates '), Staticfiles_dirs = (Os.path.join (base_dir, "statics"), # Now add the configuration, here is the tuple, note the comma # configuration Sessionsession_engine = ' d Jango.contrib.sessions.backends.db ' # engine (default) Session_cookie_name = "SessionID" # SESSION of the COOKIE is saved on the browser when the key, That is: sessionid= random string (default) Session_cookie_path = "/" # Session COOKIE saved Path (default) Session_cookie_domain = None # Session of CO Okie saved domain name (default) Session_cookie_secure = False # Whether HTTPS transport cookie (default) session_cookie_httponly = True # Whether SESSION Cookie only supports HT TP Transfer (default) Session_cookie_age = 1209600 # SESSION COOKIE Expiration date (2 weeks) (default) Session_expire_at_browser_close = False # does closing the browser make SE Ssion expired (default) Session_save_every_request = False # Whether the SESSION is saved for each request, and then saved by default (default)

view.py

From django.shortcuts import Render, redirect, Httpresponsefrom APP01 import Models

url.py

From Django.contrib import adminfrom django.urls import pathfrom django.conf.urls import URL, includefrom app01 import vie Ws

Initializing the database

Python manage.py Makemigrationspython manage.py Migrate

Python Learning---Django's new project Settings template

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.