""" Django settings for test_Bootstrap 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 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/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-#ru&o+c%h83_gp_wo=z#wub(#4vn4)xz*c2!24i1ft!+v^_unm' # 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', 'app_test.apps.AppTestConfig', 'corsheaders', 'rest_framework', 'rest_framework.authtoken', # 'django_celery_beat', ] REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework.authentication.SessionAuthentication', ], 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.IsAuthenticated', ], } 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', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', ] AUTHENTICATION_BACKENDS = [ 'django.contrib.auth.backends.ModelBackend', # ... other backends ... ] CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOWED_ORIGINS = [ "http://localhost:8501", # Streamlit 的默认端口 # 其他允许的来源 ] ROOT_URLCONF = 'test_Bootstrap.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 = 'test_Bootstrap.wsgi.application' # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'liugan_yuce', 'USER': 'postgres', 'PASSWORD': '123456', 'HOST': '127.0.0.1', 'PORT': '5432', } } # 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 = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ STATIC_URL = '/static/' # 默认登录界面 LOGIN_URL = '/login/' # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' SESSION_ENGINE = 'django.contrib.sessions.backends.db' # 或其他会话引擎 # 发送邮件相关配置 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.qq.com' EMAIL_PORT = 587 EMAIL_HOST_USER = '2298920320@qq.com' EMAIL_HOST_PASSWORD = 'hqauxjgyvbcadidb' DEFAULT_FROM_EMAIL = '2298920320@qq.com' # celery配置 CELERY_BROKER_URL = 'redis://:123456@localhost:6379/0' CELERY_RESULT_BACKEND = 'redis://:123456@localhost:6379/0' CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_TIMEZONE = 'UTC' #如果 CELERY_BEAT_SCHEDULE = { 'test-task': { 'task': 'app_test.tasks.test_task', 'schedule': crontab(minute='*/1'), }, } CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler' # settings.py # settings.py # settings.py # LOGGING = { # 'version': 1, # 'disable_existing_loggers': False, # 'handlers': { # 'console': { # 'class': 'logging.StreamHandler', # }, # 'file': { # 'level': 'DEBUG', # 'class': 'logging.FileHandler', # 'filename': 'debug.log', # }, # }, # 'loggers': { # 'django': { # 'handlers': ['console', 'file'], # 'level': 'DEBUG', # 'propagate': True, # }, # 'celery': { # 'handlers': ['console', 'file'], # 'level': 'DEBUG', # 'propagate': True, # }, # }, # }