zoukankan      html  css  js  c++  java
  • Django配置文件解释

    """
    Django settings for first project.

    Generated by 'django-admin startproject' using Django 1.11.11.

    For more information on this file, see
    https://docs.djangoproject.com/en/1.11/topics/settings/

    For the full list of settings and their values, see
    https://docs.djangoproject.com/en/1.11/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/1.11/howto/deployment/checklist/

    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = '#69g3d*dr=t@=2t(#oh)hq7josgdlxbi*%xk#zxle63dx6f+7f'

    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = True

    # 放一些指定链接的ip,*代表所有
    ALLOWED_HOSTS = ["*"]

    # Application definition


    # 我这个项目有哪些app
    INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'app.apps.AppConfig', # 告诉Django我创建了一个app
    ]

    # 中间件相关配置
    MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    # 'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ]

    ROOT_URLCONF = 'first.urls'

    TEMPLATES = [
    {
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [os.path.join(BASE_DIR, 'templates')]
    ,
    'APP_DIRS': True,
    'OPTIONS': {
    'context_processors': [
    'django.template.context_processors.debug',
    'django.template.context_processors.request',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',
    ],
    },
    },
    ]

    WSGI_APPLICATION = 'first.wsgi.application'

    # Database
    # https://docs.djangoproject.com/en/1.11/ref/settings/#databases

    DATABASES = {
    'default': {
    # 'ENGINE': 'django.db.backends.sqlite3', # 链接数据库的类型
    # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # 链接数据库的名字
    'ENGINE': 'django.db.backends.mysql', # 链接数据库的类型
    'NAME': 'db', # 链接数据库的名字
    'HOST': '127.0.0.1', # 数据库主机地址
    'PORT': 3306, # 数据库端口
    'USER': 'root', # 数据库用户名
    'PASSWORD': '123456', # 数据库密码
    }
    }

    # Password validation
    # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

    AUTH_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/1.11/topics/i18n/

    LANGUAGE_CODE = 'en-us'

    TIME_ZONE = 'UTC'

    USE_I18N = True

    USE_L10N = True

    USE_TZ = True

    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/1.11/howto/static-files/


    # 这个static就代表了下面的路径 (寻找的时候就是去static下面的路径中挨个找)
    STATIC_URL = '/static/' # 起别名, HTML中找静态文件都要以这个别名开始 (找到别名后就去这个别名的配置比文件中找对应的文件)

    # 这个常量是固定格式
    STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
    ]

  • 相关阅读:
    Java设计模式系列之策略模式
    设计模式系列之热身
    算术表达式系列之后缀表达式求值
    算术表达式系列之中缀表达式转后缀表达式
    Maven下使用Junit对Spring进行单元测试
    Windows命令行使用总结(持续更新)
    Eclipse中web项目部署至Tomcat步骤
    MyBatis保存完整日期的解决方法
    Redis(一)源码安装
    【集成学习】sklearn中xgboost模块中plot_importance函数(绘图--特征重要性)
  • 原文地址:https://www.cnblogs.com/xiao-xue-di/p/9707009.html
Copyright © 2011-2022 走看看