zoukankan      html  css  js  c++  java
  • 记录Django的settings文件常用配置

    """
    Django settings for mxOnline project.
    
    Generated by 'django-admin startproject' using Django 2.2.
    
    For more information on this file, see
    https://docs.djangoproject.com/en/2.2/topics/settings/
    
    For the full list of settings and their values, see
    https://docs.djangoproject.com/en/2.2/ref/settings/
    """
    
    import os
    import sys
    
    # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
    sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))
    
    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
    
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = '&uq@h_#x%9di$9hivu=w5#wzgp8+d8zbz^g)9cgbvy8v8agkqm'
    
    # SECURITY WARNING: don't run with debug turned on in production!
    DEBUG = False
    
    ALLOWED_HOSTS = ["*"]
    
    AUTHENTICATION_BACKENDS = (
        'users.views.CustomBancend',
    )
    
    # Application definition
    
    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'users',
    ]
    
    AUTH_USER_MODEL = "users.UserProfile"
    
    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 = 'djtest.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',
                    'django.template.context_processors.media',
                ],
            },
        },
    ]
    
    WSGI_APPLICATION = 'djtest.wsgi.application'
    
    
    # Database
    # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
    
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'django_test',
            'USER': 'pyjsh',
            'PASSWORD': 'pyjsh',
            'HOST': '127.0.0.1'
        }
    }
    
    
    # Password validation
    # https://docs.djangoproject.com/en/2.2/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.2/topics/i18n/
    
    LANGUAGE_CODE = 'zh-hans'
    
    TIME_ZONE = 'Asia/Shanghai'
    
    USE_I18N = True
    
    USE_L10N = True
    
    USE_TZ = False
    
    
    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/2.2/howto/static-files/
    
    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    # STATICFILES_DIRS = [
    #     os.path.join(BASE_DIR, 'static')
    # ]
    
    MEDIA_URL = '/media/'
    MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
    
    EMAIL_HOST = 'smtp.qq.com'
    EMAIL_PORT = 25
    EMAIL_HOST_USER = 'xxxxx@qq.com'
    EMAIL_HOST_PASSWORD = 'bghslajslas'
    EMAIL_USE_TLS = False
    EMAIL_FROM = 'xxxxx@qq.com'
    

    本文作者:温茶又折花

    本文链接: https://www.cnblogs.com/dyfblogs/p/14961492.html

    转载文章请注明作者和出处,谢谢!
  • 相关阅读:
    新年快乐,献上一份自己修改的WM6主题。
    做好MSSQL保卫战之xp_cmdshell
    [转载]Validation of viewstate MAC failed异常的原因及解决方法
    数字字符串转换为数字
    理解虚基类、虚函数与纯虚函数的概念
    你的卡销户了吗 - 中国移动收取滞纳金
    解决光驱门打不开的问题
    UCWEB使用之我见
    定时关闭窗口 For Windows Mobile SP/PPC
    减少SQL Server 死锁
  • 原文地址:https://www.cnblogs.com/dyfblogs/p/14961492.html
Copyright © 2011-2022 走看看