123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- """
- Django settings for UnTube project.
- Generated by 'django-admin startproject' using Django 3.2.3.
- 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/
- """
- import os
- from pathlib import Path
- from UnTube.secrets import SECRETS
- # Build paths inside the project like this: BASE_DIR / 'subdir'.
- # PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
- BASE_DIR = Path(__file__).resolve().parent.parent
- # BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- # 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 = SECRETS['SECRET_KEY']
- YOUTUBE_V3_API_KEY = SECRETS['YOUTUBE_V3_API_KEY']
- # SECURITY WARNING: don't run with debug turned on in production!
- DEBUG = True
- ALLOWED_HOSTS = ['127.0.0.1', 'bakaabu.pythonanywhere.com']
- # Application definition
- INSTALLED_APPS = [
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'django.contrib.humanize', # A set of Django template filters useful for adding a “human touch” to data.
- 'django.contrib.sites',
- 'allauth',
- 'allauth.account',
- 'allauth.socialaccount',
- 'allauth.socialaccount.providers.google', # specifies google as OAuth provider
- 'crispy_forms',
- 'apps.users', # has stuff related to user management in it (login, signup, show homepage, import)
- 'apps.main', # main app, shows user their homepage
- 'apps.manage_playlists',
- 'apps.charts',
- 'apps.search',
- ]
- CRISPY_TEMPLATE_PACK = 'bootstrap4'
- 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 = 'UnTube.urls'
- TEMPLATES = [
- {
- 'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [BASE_DIR / 'templates'],
- # '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',
- ],
- },
- },
- ]
- AUTHENTICATION_BACKENDS = [
- 'django.contrib.auth.backends.ModelBackend',
- 'allauth.account.auth_backends.AuthenticationBackend'
- ]
- SOCIALACCOUNT_PROVIDERS = {
- 'google': {
- 'SCOPE': [
- 'profile',
- 'email',
- 'https://www.googleapis.com/auth/youtube',
- ],
- 'AUTH_PARAMS': {
- # To refresh authentication in the background, set AUTH_PARAMS['access_type'] to offline.
- 'access_type': 'offline',
- }
- }
- }
- SITE_ID = 7
- LOGIN_URL = '/'
- LOGIN_REDIRECT_URL = '/home/'
- LOGOUT_REDIRECT_URL = '/home/'
- WSGI_APPLICATION = 'UnTube.wsgi.application'
- # Database
- # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': BASE_DIR / 'db.sqlite3',
- }
- }
- # DATABASES = {}
- # DATABASES['default'] = dj_database_url.config(conn_max_age=600)
- # DATABASE_URL = os.environ['DATABASE_URL']
- # conn = psycopg2.connect(DATABASE_URL, sslmode='require')
- # 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/'
- STATIC_ROOT = os.path.join(BASE_DIR, 'static')
- # STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
- # Default primary key field type
- # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
- DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
- # django_heroku.settings(locals())
- # options = DATABASES['default'].get('OPTIONS', {})
- # options.pop('sslmode', None)
|