Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Untested setup. If you run this and complain I'm not going to listen.…
Browse files Browse the repository at this point in the history
… Let me finish please
  • Loading branch information
pydanny committed Aug 28, 2012
1 parent 879792f commit 8041bfd
Show file tree
Hide file tree
Showing 37 changed files with 8,479 additions and 6 deletions.
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Some helpful utility commands.
# TODO - maybe convert to Fabric scripts

deploy:
heroku pgbackups:capture --expire
git push heroku master
heroku run python {{ project_name }}/manage.py syncdb --noinput --settings={{ project_name }}.settings.heroku
heroku run python {{ project_name }}/manage.py migrate --settings={{ project_name }}.settings.heroku

style:
git push heroku master
heroku run python {{ project_name }}/manage.py collectstatic --noinput --settings={{ project_name }}.settings.heroku

restorepgsql:
heroku pgbackups:capture --expire
curl -o latest.dump `heroku pgbackups:url`
dropdb {{ project_name }}
createdb {{ project_name }}
pg_restore --verbose --clean --no-acl --no-owner -d {{ project_name }} latest.dump
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: python {{ project_name }}/manage.py run_gunicorn --settings={{ project_name }}.settings.heroku -b "0.0.0.0:$PORT" -w 3
4 changes: 1 addition & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
django-party-pack
==================

Combining the Django Tutorial with Sphinx Docs, Django-Coverage, Coverage.py, and some notes on good practices

Installation and documentation is at http://readthedocs.org/docs/django-party-pack/en/latest/
My simple and easy-to-use Django project template.


Binary file added project_name/.DS_Store
Binary file not shown.
10 changes: 10 additions & 0 deletions project_name/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings.dev")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
Empty file.
Empty file.
153 changes: 153 additions & 0 deletions project_name/project_name/settings/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Django settings for {{ project_name }} project.

import os.path

PROJECT_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
if '{{ project_name }}/{{ project_name }}' in PROJECT_ROOT:
PROJECT_ROOT = PROJECT_ROOT.replace('{{ project_name }}/', '')

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS


TIME_ZONE = 'America/Los_Angeles'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

USE_I18N = True
USE_L10N = True
USE_TZ = True

MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'collected_static')
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '{{ secret_key }}'

# List of callables that know how to import templates from various sources.
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.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)

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",
]

ROOT_URLCONF = '{{ project_name }}.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = '{{ project_name }}.wsgi.application'

TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, '{{ project_name }}/templates'),
)

BASE_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',

'gunicorn',
'django_extensions',
'south',
'crispy_forms',
'floppyforms',
'braces',
'registration',
)

PROJECT_APPS = ()

INSTALLED_APPS = BASE_APPS + PROJECT_APPS

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}

EMAIL_SUBJECT_PREFIX = '[{{ project_name }}]'

# DO MEMCACHE
from memcacheify import memcacheify
CACHES = memcacheify()
CACHE_COUNT_TIMEOUT = 60 # seconds, not too long.


# django-registration
ACCOUNT_ACTIVATION_DAYS = 3

CRISPY_TEMPLATE_PACK = "bootstrap"

THUMBNAIL_DEBUG = True


LOGIN_REDIRECT_URL = "/"
LOGIN_URL = "/log-in/"
26 changes: 26 additions & 0 deletions project_name/project_name/settings/dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from base import *

EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '{{ project_name }}',
'USER': '',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '',
}
}


MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
INSTALLED_APPS += ('debug_toolbar',)

INTERNAL_IPS = ('127.0.0.1',)

DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TEMPLATE_CONTEXT': True,
}
62 changes: 62 additions & 0 deletions project_name/project_name/settings/heroku.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from base import *

import os

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = (
('YOUR NAME', 'yourname@example.com'),
)

MANAGERS = ADMINS

DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL',
'LA Currents <info@{{ project_name }}.com>')
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_PASSWORD = os.environ.get('SENDGRID_PASSWORD')
EMAIL_HOST_USER = os.environ.get('SENDGRID_USERNAME')
EMAIL_PORT = os.environ.get('EMAIL_PORT', 587)
SERVER_EMAIL = 'info@{{ project_name }}.com'
EMAIL_USE_TLS = True


from postgresify import postgresify

DATABASES = postgresify()


########## STORAGE CONFIGURATION
INSTALLED_APPS += ('storages', 'raven.contrib.django', )

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

AWS_QUERYSTRING_AUTH = False

AWS_HEADERS = {
'Expires': 'Thu, 15 Apr 2020 20:00:00 GMT',
'Cache-Control': 'max-age=86400',
}

# Boto requires subdomain formatting.
from S3 import CallingFormat
AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN

# Amazon S3 configuration.
if 'AWS_ACCESS_KEY_ID' in os.environ:
AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID']
else:
raise Exception("Missing AWS_ACCESS_KEY_ID")

if 'AWS_SECRET_ACCESS_KEY' in os.environ:
AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY']
else:
raise Exception("Missing AWS_SECRET_ACCESS_KEY")

AWS_STORAGE_BUCKET_NAME = '{{ project_name }}'

STATIC_URL = 'https://s3.amazonaws.com/{{ project_name }}/'
MEDIA_URL = STATIC_URL
########## END STORAGE CONFIGURATION
30 changes: 30 additions & 0 deletions project_name/project_name/settings/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from base import *

# DO TEST COVERAGE
######### DEBUG
DEBUG = True
TEMPLATE_DEBUG = DEBUG
SERVE_MEDIA = DEBUG

INSTALLED_APPS += ('django_coverage', )

TEST_RUNNER = 'testrunner.OurCoverageRunner'
COVERAGE_MODULE_EXCLUDES = (
'tests$', 'settings$', 'urls$', 'locale$',
'migrations', 'fixtures', 'debug_toolbar',
'admin',
)
COVERAGE_MODULE_EXCLUDES += BASE_APPS
COVERAGE_REPORT_HTML_OUTPUT_DIR = "coverage"

########## DATABASES
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
"USER": "",
"PASSWORD": "",
"HOST": "",
"PORT": "",
},
}
19 changes: 19 additions & 0 deletions project_name/project_name/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',

url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('registration.backends.default.urls')),
)


if settings.DEBUG:
urlpatterns += patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
)
28 changes: 28 additions & 0 deletions project_name/project_name/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
WSGI config for {{ project_name }} project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
Loading

0 comments on commit 8041bfd

Please sign in to comment.