Setup fixes

This commit is contained in:
Daniel Greenfeld 2013-08-16 15:52:03 +02:00
parent eb35064b13
commit d58da9e5e8
5 changed files with 18 additions and 22 deletions

View File

@ -6,6 +6,8 @@ django-braces==1.2.2
django-model-utils==1.4.0 django-model-utils==1.4.0
django-floppyforms==1.1 django-floppyforms==1.1
Pillow==2.1.0 Pillow==2.1.0
dj-database-url==0.2.2
django-secure==1.0
# For user registration, either via email or social # For user registration, either via email or social
# Well-built with regular release cycles! # Well-built with regular release cycles!

View File

@ -11,17 +11,20 @@ https://docs.djangoproject.com/en/dev/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os import os
from os.path import abspath, basename, dirname, join, normpath from os.path import join
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) BASE_DIR = os.path.dirname(os.path.dirname(__file__))
########## DEBUG CONFIGURATION
if os.environ.get("DATABASE_URL", None): if os.environ.get("DATABASE_URL", None):
########## DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = False DEBUG = False
else:
DEBUG = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION ########## END DEBUG CONFIGURATION
########## SECRET CONFIGURATION ########## SECRET CONFIGURATION
@ -54,7 +57,7 @@ MANAGERS = ADMINS
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
import dj_database_url import dj_database_url
DATABASES = {'default': dj_database_url.config()} DATABASES = {'default': dj_database_url.config()}
if DATABASES == {}: if DATABASES == {'default': {}}:
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
@ -100,7 +103,6 @@ MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
#'djstripe.middleware.SubscriptionPaymentMiddleware', # TODO fix this by settings
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
) )
########## END MIDDLEWARE CONFIGURATION ########## END MIDDLEWARE CONFIGURATION
@ -141,11 +143,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request', 'django.core.context_processors.request',
) )
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
@ -201,10 +198,10 @@ INSTALLED_APPS += (
########## URL Configuration ########## URL Configuration
ROOT_URLCONF = '{{cookiecutter.repo_nam}}.urls' ROOT_URLCONF = 'config.urls'
# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
WSGI_APPLICATION = '{{cookiecutter.repo_nam}}.wsgi.application' WSGI_APPLICATION = 'config.wsgi.application'
########## End URL Configuration ########## End URL Configuration
########## django-secure ########## django-secure
@ -308,7 +305,7 @@ else:
########## EMAIL ########## EMAIL
DEFAULT_FROM_EMAIL = environ.get('DEFAULT_FROM_EMAIL', DEFAULT_FROM_EMAIL = environ.get('DEFAULT_FROM_EMAIL',
'{{cookiecutter.project_name}} <{{cookiecutter.project_name}}-noreply@{{cookiecutter.domain_name}}>') '{{cookiecutter.project_name}} <{{cookiecutter.project_name}}-noreply@{{cookiecutter.doman_name}}>')
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = environ.get('EMAIL_HOST', 'smtp.sendgrid.com') EMAIL_HOST = environ.get('EMAIL_HOST', 'smtp.sendgrid.com')
EMAIL_HOST_PASSWORD = os.environ.get('SENDGRID_PASSWORD', '') EMAIL_HOST_PASSWORD = os.environ.get('SENDGRID_PASSWORD', '')
@ -350,4 +347,4 @@ LOGGING = {
}, },
} }
} }
########## END LOGGING CONFIGURATION ########## END LOGGING CONFIGURATION

View File

@ -21,7 +21,7 @@ SITE_ROOT = dirname(dirname(abspath(__file__)))
path.append(SITE_ROOT) path.append(SITE_ROOT)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ cookiecutter.repo_name }}.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application

View File

@ -3,7 +3,7 @@ import os
import sys import sys
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.config.local") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Import the reverse lookup function # Import the reverse lookup function
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db.models import Count, Sum
# view imports # view imports
from django.views.generic import DetailView from django.views.generic import DetailView
@ -15,8 +14,6 @@ from braces.views import LoginRequiredMixin
# Import the form from users/forms.py # Import the form from users/forms.py
from .forms import UserForm from .forms import UserForm
from djstripe.mixins import SubscriptionPaymentRequiredMixin
# Import the customized User model # Import the customized User model
from .models import User from .models import User
@ -53,7 +50,7 @@ class UserUpdateView(LoginRequiredMixin, UpdateView):
return User.objects.get(username=self.request.user.username) return User.objects.get(username=self.request.user.username)
class UserListView(LoginRequiredMixin, SubscriptionPaymentRequiredMixin, ListView): class UserListView(LoginRequiredMixin, ListView):
model = User model = User
# These next two lines tell the view to index lookups by username # These next two lines tell the view to index lookups by username
slug_field = "username" slug_field = "username"