Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from pathlib import Path
- # used to generate the SECRET_KEY
- from django.core.exceptions import ImproperlyConfigured
- from dotenv import load_dotenv
- load_dotenv()
- # 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/4.2/howto/deployment/checklist/
- # SECURITY WARNING: don't run with debug turned on in production!
- DEBUG = True
- # Application definition
- INSTALLED_APPS = [
- "django.contrib.admin",
- "django.contrib.auth",
- "django.contrib.contenttypes",
- "django.contrib.sessions",
- "django.contrib.messages",
- "django.contrib.staticfiles",
- "django.contrib.sites",
- # External Packages
- "rest_framework",
- "rest_framework.authtoken",
- # "corsheaders",
- "drf_spectacular",
- "allauth",
- "allauth.account",
- "allauth.socialaccount",
- # Allauth Third-party Providers
- "allauth.socialaccount.providers.facebook",
- "allauth.socialaccount.providers.github",
- "allauth.socialaccount.providers.google",
- # Internal Apps
- "myapp",
- "myotherapp",
- "severalmoreapps",
- ]
- MIDDLEWARE = [
- "django.middleware.security.SecurityMiddleware",
- # Whitenoise enables static files in production
- "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",
- ]
- REST_FRAMEWORK = {
- "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
- "DEFAULT_AUTHENTICATION_CLASSES": [
- "rest_framework.authentication.TokenAuthentication",
- "rest_framework.authentication.BasicAuthentication",
- ],
- # This sets all classes and functions as requiring user authentication
- "DEFAULT_PERMISSION_CLASSES": [
- # "rest_framework.permissions.IsAuthenticated",
- "rest_framework.permissions.IsAdminUser"
- ],
- }
- ROOT_URLCONF = "project.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",
- # `allauth` needs this
- "django.template.context_processors.request",
- ],
- },
- },
- ]
- WSGI_APPLICATION = "project.wsgi.application"
- # Database section
- # Password validation
- # https://docs.djangoproject.com/en/4.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/4.2/topics/i18n/
- LANGUAGE_CODE = "en-us"
- TIME_ZONE = "UTC"
- USE_I18N = True
- USE_TZ = True
- DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
- SPECTACULAR_SETTINGS = {
- "TITLE": "Eve-Connect Backend",
- }
- SITE_ID = 1
- AUTHENTICATION_BACKENDS = [
- # Needed to login by username in Django admin, regardless of `allauth`
- "django.contrib.auth.backends.ModelBackend",
- # `allauth` specific authentication methods, such as login by e-mail
- "allauth.account.auth_backends.AuthenticationBackend",
- ]
- EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
- ACCOUNT_USERNAME_REQUIRED = False
- ACCOUNT_AUTHENTICATION_METHOD = "email"
- ACCOUNT_EMAIL_REQUIRED = True
- ACCOUNT_UNIQUE_EMAIL = True
- SOCIALACCOUNT_PROVIDERS = {
- "google": {
- "SCOPE": [
- "profile",
- "email",
- ],
- "AUTH_PARAMS": {
- "access_type": "online",
- },
- "OAUTH_PKCE_ENABLED": True,
- },
- "facebook": {
- "METHOD": "oauth2",
- "SDK_URL": "//connect.facebook.net/{locale}/sdk.js",
- "SCOPE": ["email", "public_profile"],
- "AUTH_PARAMS": {"auth_type": "reauthenticate"},
- "INIT_PARAMS": {"cookie": True},
- "FIELDS": [
- "id",
- "first_name",
- "last_name",
- "middle_name",
- "name",
- "name_format",
- "picture",
- "short_name",
- ],
- "EXCHANGE_TOKEN": True,
- "VERIFIED_EMAIL": False,
- "VERSION": "v13.0",
- "GRAPH_API_URL": "https://graph.facebook.com/v13.0",
- },
- }
- STATIC_URL = "static/"
- STATIC_FILES_DIRS = [os.path.join(BASE_DIR, "static")]
- STATIC_ROOT = os.path.join(BASE_DIR, "staticroot")
Advertisement
Add Comment
Please, Sign In to add comment