• Django settings 配置文件


    """
    Django settings for mysite project.
    
    Generated by 'django-admin startproject' using Django 2.0.2.
    
    For more information on this file, see
    https://docs.djangoproject.com/en/2.0/topics/settings/
    
    For the full list of settings and their values, see
    https://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 = '*450&)6_2rp0qrqa6_r!k0d5-t%jfn*a9o=lgjy8d5+x)xex9r'
    
    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = True
    
    ALLOWED_HOSTS = []
    
    
    # Application definition
    
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'blog.apps.BlogConfig',
    ]
    
    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
       #跳转相同的界面会提示一个403 的错误, 这是因为防止表单攻击而引入的,注释这一行将避免错误
       # 'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ]
    
    ROOT_URLCONF = 'mysite.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 = 'mysite.wsgi.application'
    
    
    # Database
    # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
    
    #数据库相关的文件
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        }
    }
    
    
    # Password validation
    # https://docs.djangoproject.com/en/2.0/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/2.0/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/2.0/howto/static-files/
    
    #这个参数就是把STATICFILES_DIRS  进行一个重命名,引用的时候直接/static/xxx/xxx.js
    STATIC_URL = '/abc/'
    
    
    #存储静态文件比如 js,css , 图片
    STATICFILES_DIRS=(
        os.path.join(BASE_DIR,"statics"),
    )


    TEMPLATES 存储模板相关的文件,'DIRS': [os.path.join(BASE_DIR, 'templates')] 作用是获取模板的路径

    DATABASES 数据库相关的信息

    STATICFILES_DIRS 存储静态文件比如 js,css , 图片

    STATIC_URL 这个参数就是把STATICFILES_DIRS 进行一个重命名,引用的时候直接/abc/xxx/xxx.js。如何静态文件的文件夹name 发生改变,通过STATIC_URL 访问静态文件的URL 不需要改变,仍然是/abc/xxx/xxx.js

  • 相关阅读:
    教你用纯Java实现一个网页版的Xshell(附源码)
    Learn Terraform--Getting Started--Installing Terraform
    Install Terraform on Windows, Linux and Mac OS
    Installing kubectl
    Creating a Cron Job in K8S
    Patch multi versions of windows via Power shell
    Bash to check SSL cert expired
    K8S dashboard 创建只读账户
    K8S Link
    Kubernetes
  • 原文地址:https://www.cnblogs.com/gaizhongfeng/p/8757671.html
Copyright © 2020-2023  润新知