""" Django settings for admin_site project. Generated by 'django-admin startproject' using Django 4.1.dev20220419193849. For more information on this file, see https://docs.djangoproject.com/en/dev/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/dev/ref/settings/ """ from pathlib import Path from celery.schedules import crontab # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-!0(t*tv28%v-igloc5$)-j1optl#e-e!7-x!5xt8p6k8t9u&yp' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] APPEND_SLASH = False # Application definition INSTALLED_APPS = [ 'user', 'order', 'files', 'sick', 'django_celery_beat', 'django_celery_results', 'corsheaders', 'rest_framework', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', # 注册中间件 '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 = 'admin_site.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], '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 = 'admin_site.wsgi.application' # Database # https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = { 'default': { # 'ENGINE': 'django.db.backends.mysql', # 数据库引擎 # 'NAME': 'mysite', # 数据库名,先前创建的 # 'USER': 'root', # 用户名,可以自己创建用户 # 'PASSWORD': '', # 密码 # 'HOST': '127.0.0.1', # mysql服务所在的主机ip # 'PORT': '3306', # mysql服务端口 'ENGINE': 'django.db.backends.sqlite3', # 数据库引擎 'NAME': BASE_DIR / 'mysite', # 数据库名,先前创建的 # 'USER': 'root', # 用户名,可以自己创建用户 # 'PASSWORD': '132546tt', # 密码 # 'HOST': 'mysql://gz-cdb-pb7zuqlf.sql.tencentcdb.com', # mysql服务所在的主机ip # 'PORT': '63825', # mysql服务端口 } } # Password validation # https://docs.djangoproject.com/en/dev/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/dev/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/dev/howto/static-files/ STATIC_URL = 'static/' # Default primary key field type # https://docs.djangoproject.com/en/dev/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' # 允许全部来源 CORS_ORIGIN_ALLOW_ALL = True # 如果为True,将不使用白名单,并且将接受所有来源。默认为False。 # Celery settings Start CELERY_BROKER_URL = 'redis://localhost:6379/1' CELERY_ACCEPT_CONTENT = ['json'] CELERY_RESULT_BACKEND = 'redis://localhost:6379/0' CELERY_TASK_SERIALIZER = 'json' CELERY_BEAT_SCHEDULE = { 'task-name': { 'task': 'files.tasks.del_file', 'schedule': crontab(hour='*/1'), # 每隔1小时删除用户未使用的,且上传时间大于4小时的文件 # 'args': (1, 2), }, } # Celery settings End