184 lines
4.7 KiB
Python
184 lines
4.7 KiB
Python
"""
|
|
Django settings for AssetManagement project.
|
|
|
|
Generated by 'django-admin startproject' using Django 3.2.
|
|
|
|
For more information on this file, see
|
|
https://docs.djangoproject.com/en/3.2/topics/settings/
|
|
|
|
For the full list of settings and their values, see
|
|
https://docs.djangoproject.com/en/3.2/ref/settings/
|
|
"""
|
|
|
|
from ctypes import cast
|
|
from pathlib import Path
|
|
from dotenv import load_dotenv
|
|
import os
|
|
from decouple import config
|
|
|
|
|
|
|
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
load_dotenv()
|
|
LOGIN_REDIRECT_URL = '/'
|
|
|
|
|
|
# Quick-start development settings - unsuitable for production
|
|
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
# SECRET_KEY = os.environ.get('SECRET_KEY')
|
|
SECRET_KEY = "django-insecure-^o6u10km7xey-)n6ng+hh2rxm+ydcvor*)$fnl7)3_i)nu)a&x"
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = config('DEBUG')
|
|
|
|
ALLOWED_HOSTS = ['*']
|
|
|
|
LOCALHOST_URL = 'http:127.0.0.1:8000'
|
|
DEV_URL = os.environ.get('DEV_URL') if os.getcwd() == "/app" else None
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
|
|
'authentication',
|
|
'vendors',
|
|
'products',
|
|
'assets',
|
|
'dashboard',
|
|
'recycle_bin',
|
|
'upload',
|
|
'error_handlers',
|
|
|
|
'smart_selects',
|
|
'roles',
|
|
'users',
|
|
'support',
|
|
'notifications',
|
|
'simple_history'
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
|
'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',
|
|
'simple_history.middleware.HistoryRequestMiddleware'
|
|
]
|
|
|
|
ROOT_URLCONF = 'AssetManagement.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [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 = 'AssetManagement.wsgi.application'
|
|
|
|
|
|
# Database
|
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
|
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
'NAME': 'eamtest', # 数据库名字
|
|
'USER': 'root',
|
|
'PASSWORD': 'guoan123',
|
|
'HOST': '127.0.0.1',
|
|
'PORT': 3306,
|
|
}
|
|
}
|
|
|
|
# Password validation
|
|
# https://docs.djangoproject.com/en/3.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/3.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/3.2/howto/static-files/
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
|
|
|
STATICFILES_DIRS = [
|
|
BASE_DIR/'static'
|
|
]
|
|
|
|
MEDIA_URL = '/media/'
|
|
|
|
MEDIA_ROOT = BASE_DIR / 'media'
|
|
|
|
# Default primary key field type
|
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
AUTH_USER_MODEL = 'authentication.User'
|
|
LOGIN_URL = 'authentication:login'
|
|
|
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
|
|
|
EMAIL_HOST = os.environ.get('EMAIL_HOST')
|
|
EMAIL_PORT = os.environ.get('EMAIL_PORT')
|
|
EMAIL_USE_TLS = True
|
|
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
|
|
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
|
|
|
|
#Image Processing
|
|
DJANGORESIZED_DEFAULT_SIZE = [1024, 768]
|
|
DJANGORESIZED_DEFAULT_QUALITY = 75
|
|
DJANGORESIZED_DEFAULT_KEEP_META = True
|
|
DJANGORESIZED_DEFAULT_FORCE_FORMAT = 'JPEG'
|
|
DJANGORESIZED_DEFAULT_FORMAT_EXTENSIONS = {'JPEG': ".jpg"}
|
|
DJANGORESIZED_DEFAULT_NORMALIZE_ROTATION = True |