Rework settings, add apps.py, preping for django 1.10 upgrade

This commit is contained in:
Isaac Bythewood
2016-11-28 16:58:34 -05:00
parent 78f1fbdb30
commit 6bb7a96ddc
9 changed files with 170 additions and 131 deletions

1
.gitignore vendored
View File

@@ -26,6 +26,7 @@
# Project
/*.db
/*.sqlite3
# Misc
/.idea/

View File

@@ -3,7 +3,7 @@ import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings.development")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings")
from django.core.management import execute_from_command_line

7
pinry/core/apps.py Normal file
View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
from django.apps import AppConfig
class CoreConfig(AppConfig):
name = 'core'

153
pinry/settings.py Normal file
View File

@@ -0,0 +1,153 @@
import os
from django.contrib.messages import constants as messages
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'REPLACE-ME'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# SECURITY WARNING: use your actual domain name in production!
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'taggit',
'compressor',
'django_images',
'pinry.core',
'pinry.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',
'pinry.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',
],
},
},
]
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'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# 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 = False
# Set to False to force users to login before seeing any pins.
PUBLIC = True
AUTHENTICATION_BACKENDS = [
'pinry.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
IMAGE_PATH = 'pinry.core.utils.upload_path'
IMAGE_SIZES = {
'thumbnail': {'size': [240, 0]},
'standard': {'size': [600, 0]},
'square': {'crop': True, 'size': [125, 125]},
}

View File

@@ -1,94 +0,0 @@
import os
from django.contrib.messages import constants as messages
SITE_ROOT = os.path.join(os.path.realpath(os.path.dirname(__file__)), '../../')
# Set to False to disable people from creating new accounts.
ALLOW_NEW_REGISTRATIONS = False
# Set to False to force users to login before seeing any pins.
PUBLIC = True
TIME_ZONE = 'America/New_York'
LANGUAGE_CODE = 'en-us'
USE_I18N = True
USE_L10N = True
USE_TZ = True
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(SITE_ROOT, 'media')
STATIC_ROOT = os.path.join(SITE_ROOT, 'static')
TEMPLATE_DIRS = [os.path.join(SITE_ROOT, 'pinry/templates')]
STATICFILES_DIRS = [os.path.join(SITE_ROOT, 'pinry/static')]
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder'
)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'pinry.users.middleware.Public',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
'pinry.core.context_processors.template_settings',
)
AUTHENTICATION_BACKENDS = (
'pinry.users.auth.backends.CombinedAuthBackend',
'django.contrib.auth.backends.ModelBackend',
)
ROOT_URLCONF = 'pinry.urls'
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
INTERNAL_IPS = ['127.0.0.1']
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
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'taggit',
'compressor',
'django_images',
'pinry.core',
'pinry.users',
)
IMAGE_PATH = 'pinry.core.utils.upload_path'
IMAGE_SIZES = {
'thumbnail': {'size': [240, 0]},
'standard': {'size': [600, 0]},
'square': {'crop': True, 'size': [125, 125]},
}

View File

@@ -1,17 +0,0 @@
from pinry.settings import *
import os
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = ['*']
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(SITE_ROOT, 'development.db'),
}
}
SECRET_KEY = 'fake-key'

View File

@@ -1,18 +0,0 @@
from pinry.settings import *
import os
DEBUG = False
TEMPLATE_DEBUG = DEBUG
# TODO: I recommend using psycopg2 w/ postgres but sqlite3 is good enough.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(SITE_ROOT, 'production.db'),
}
}
# TODO: Be sure to set this.
SECRET_KEY = ''

7
pinry/users/apps.py Normal file
View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
from django.apps import AppConfig
class UsersConfig(AppConfig):
name = 'users'

View File

@@ -1,7 +1,7 @@
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings.production")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings")
from django.core.wsgi import get_wsgi_application