Files
Pinry/pinry/settings/base.py

160 lines
4.0 KiB
Python
Raw Normal View History

import os
from django.contrib.messages import constants as messages
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
2019-02-19 18:19:12 +08:00
'rest_framework',
'django_filters',
'taggit',
'compressor',
'django_images',
2018-02-08 21:57:49 -05:00
'core',
'users',
]
ROOT_URLCONF = 'pinry.urls'
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
2018-02-08 21:57:49 -05:00
'users.middleware.Public',
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'pinry/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',
2018-02-08 21:57:49 -05:00
'core.context_processors.template_settings',
],
},
},
]
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
]
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'pinry/static')]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media')
WSGI_APPLICATION = 'pinry.wsgi.application'
# Password validation
# https://docs.djangoproject.com/en/1.10/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/1.10/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/1.10/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/static/media/'
# Set to False to disable people from creating new accounts.
ALLOW_NEW_REGISTRATIONS = True
# Set to False to force users to login before seeing any pins.
PUBLIC = True
AUTHENTICATION_BACKENDS = [
2018-02-08 21:57:49 -05:00
'users.auth.backends.CombinedAuthBackend',
'django.contrib.auth.backends.ModelBackend',
]
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
MESSAGE_TAGS = {
messages.WARNING: 'alert alert-warning',
messages.ERROR: 'alert alert-danger',
messages.SUCCESS: 'alert alert-success',
messages.INFO: 'alert alert-info',
}
API_LIMIT_PER_PAGE = 50
2018-02-08 21:57:49 -05:00
IMAGE_PATH = 'core.utils.upload_path'
IMAGE_SIZES = {
'thumbnail': {'size': [240, 0]},
'standard': {'size': [600, 0]},
'square': {'crop': True, 'size': [125, 125]},
}
# IS_TEST is a variable to mark if the test is running
IS_TEST = False
# User custom settings
IMAGE_AUTO_DELETE = True
2019-02-19 18:19:12 +08:00
# Rest Framework
DRF_URL_FIELD_NAME = "resource_link"
2019-02-19 18:19:12 +08:00
REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
2019-02-20 17:40:06 +08:00
'rest_framework.permissions.IsAuthenticatedOrReadOnly'
],
'DEFAULT_FILTER_BACKENDS': (
'django_filters.rest_framework.DjangoFilterBackend',
),
'URL_FIELD_NAME': DRF_URL_FIELD_NAME,
2019-02-19 18:19:12 +08:00
}