"""
Django settings for alimento project.

Generated by 'django-admin startproject' using Django 3.1.1.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
from django.contrib.messages import constants
import os

# 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.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'o4acq-lpts90f&@#(%ofig8g1ewjx#s)6=7n2+g_ug^#6dw-0l'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

LOGIN_REDIRECT_URL = 'home'
# Application definition

INSTALLED_APPS = [
    'ckeditor',
    'widget_tweaks',
    'webpages.apps.WebpagesConfig',
    'accounts.apps.AccountsConfig',
    'menus.apps.MenusConfig',
    'djangocms_admin_style',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.github',
    'allauth.socialaccount.providers.twitter',
    'allauth.socialaccount.providers.linkedin_oauth2',
]

SITE_ID = 1

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 = 'alimento.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        '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',
            ],
        },
    },
]

WSGI_APPLICATION = 'alimento.wsgi.application'



# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'alimento',#Name of the database. First make it in postgresql and then mention it here.
        'USER':'postgres',  #name of the owner field while we were creatin database and it remains as "postgres", most of the times.
        'PASSWORD':'achintya1',
        'HOST':'localhost'
        # After these settings just run the command "pip install psycopg2"
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.1/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',
    },
]

MESSAGE_TAGS = {
    constants.ERROR: 'danger', # set the tag of ERROR level as 'danger'
}


# Internationalization
# https://docs.djangoproject.com/en/3.1/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.1/howto/static-files/




STATIC_URL = '/static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR,'alimento/static'),
]

STATIC_ROOT = os.path.join(BASE_DIR,'static')


# Django looks for static files in all the apps of the project as well as at the locations mentioned in STATICFILE_DIRS and after running the "python manage.py collectstatic" command, it will copy and place all the static files present in our project, inside STATIC_ROOT folder.
# STATIC_URL is the url through which it will be served on the internet i.e., "http://127.0.0.1:8000/static/css/ach_home_style.css"

#*****************__IMPORTANT__***************************************

#1.  All the static files are not being served from STATIC_ROOT folder but from app's static folder and STATICFILE_DIRS mentioned locations . STATIC_ROOT folder is used at the time of deployment on a real server and all static files are served from it.

#2. if "django.contrib.staticfiles" is removed from "INSTALLED_APPS" and then "urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)" is used , then we are serving the static files from our devlopment server otherwise if it is present in INSTALLED_APPS, then by running "runserver" command all the static files are automatically served.

#3. MEDIA_URL and MEDIA_ROOT are used for "images/files uploaded by the user".

#********************************************************************


MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')