"""
Django settings for trydjango project.

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

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

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

SuperUser:
Admin
p@ssw0rd
"""

"""
Use 'python manage.py migrate' to sync settings onto the apps of this project.

To create apps you should use 'python manage.py startapp <appname>'.
Each app can do everything by itself but design-wise you create multiple apps that each do one thing very well. The apps in this case are the folders: blog, courses, pages, and products.
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
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/2.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '@hh&)hed7(d*lqzlipkt)6)hdahnc$vz8*q&gulc%mp^xt5q=3='

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

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [ # More like Components that are little pieces of a greater project.
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # third party

    # include your own apps here
    'blog',
    'courses',
    'pages', # This is to set an app that will deal with the webpages.
    'products', # Refer to 'products/admin.py'. Always 'python manage.py makemigration' since you are now messing with the DB. To implement you DB you have type 'python manage.py migrate' after. Go back to 'products/models.py' to learn about adding records with python shell.
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',

    'django.middleware.csrf.CsrfViewMiddleware',
    # From: https://docs.djangoproject.com/en/2.2/ref/csrf/
# Cross Site Request Forgery protection¶
#     The CSRF middleware and template tag provides easy-to-use protection against Cross Site
#     Request Forgeries (https://www.squarefree.com/securitytips/web-developers.html#CSRF).
#     This type of attack occurs when a malicious website contains a link, a form button or some
#     JavaScript that is intended to perform some action on your website, using the credentials
#     of a logged-in user who visits the malicious site in their browser. A related type of
#     attack, ‘login CSRF’, where an attacking site tricks a user’s browser into logging into
#     a site with someone else’s credentials, is also covered.

#     The first defense against CSRF attacks is to ensure that GET requests (and other ‘safe’ methods, as defined by RFC 7231#section-4.2.1[https://tools.ietf.org/html/rfc7231.html#section-4.2.1]) are side effect free.

    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'trydjango.urls' # How Django knows to route any given URLs.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',

        
        # From: https://docs.djangoproject.com/en/2.2/topics/templates/
        # Being a web framework, Django needs a convenient way to generate HTML dynamically.
        #  The most common approach relies on templates. A template contains the static 
        #  parts of the desired HTML output as well as some special syntax describing how 
        #  dynamic content will be inserted.
       

        'DIRS': [os.path.join(BASE_DIR, "templates")], # Here is 'DIRS' is where you manually set the path to your 'templates/' folder.
        '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 = 'trydjango.wsgi.application' # This is how your server works. It goes though this setting. Some cases you change it and in others you leave it alone.


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Change where .sqlite3 is to change different Database Management System.
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # Must also place location of new DBMS. Check documentation.
        # Fun fact--> 'NAME': os.path.join(BASE_DIR, 'db2.sqlite3'), --> will create another DB called db2.sqlite3 next to db.sqlite3. You have to type 'python manage.py migrate' to implement though. You should do that every time you change the settings of 'settings.py' or DB Models which will be discussed later.
    }
}


# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [ # Validates passwords to current standard.
    {
        '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/2.0/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/2.0/howto/static-files/

STATIC_URL = '/static/'

