Commits

Dan Watson committed ed341ad

Updated structure for Django 1.4

  • Participants
  • Parent commits e3a60b2

Comments (0)

Files changed (8)

 ^static/.*
 ^media/.*
 ^.*\.db$
-^local_settings.py$
+local_settings.py$

__init__.py

Empty file removed.

leaves/settings.py

+import os
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+ADMINS = (
+	# ('Your Name', 'your_email@example.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASES = {
+	'default': {
+		'ENGINE': 'django.db.backends.sqlite3',		 # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+		'NAME': os.path.join(BASE_DIR, 'leaves.db'), # Or path to database file if using sqlite3.
+		'USER': '',									 # Not used with sqlite3.
+		'PASSWORD': '',								 # Not used with sqlite3.
+		'HOST': '',									 # Set to empty string for localhost. Not used with sqlite3.
+		'PORT': '',									 # Set to empty string for default. Not used with sqlite3.
+	}
+}
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# On Unix systems, a value of None will cause Django to use the same
+# timezone as the operating system.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Support some of the more "common" languages by default.
+gettext_noop = lambda s: s
+LANGUAGES = (
+	('de', gettext_noop('German')),
+	('el', gettext_noop('Greek')),
+	('en', gettext_noop('English')),
+	('es', gettext_noop('Spanish')),
+	('fr', gettext_noop('French')),
+	('it', gettext_noop('Italian')),
+	('ja', gettext_noop('Japanese')),
+	('no', gettext_noop('Norwegian')),
+	('ko', gettext_noop('Korean')),
+	('pl', gettext_noop('Polish')),
+	('pt', gettext_noop('Portuguese')),
+	('ru', gettext_noop('Russian')),
+	('sv', gettext_noop('Swedish')),
+	('vi', gettext_noop('Vietnamese')),
+	('zh-cn', gettext_noop('Simplified Chinese')),
+	('zh-tw', gettext_noop('Traditional Chinese')),
+)
+
+# 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
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale.
+USE_L10N = True
+
+# If you set this to False, Django will not use timezone-aware datetimes.
+USE_TZ = True
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/home/media/media.lawrence.com/media/"
+MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
+MEDIA_URL = '/media/'
+
+# Absolute path to the directory static files should be collected to.
+# Don't put anything in this directory yourself; store your static files
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
+# Example: "/home/media/media.lawrence.com/static/"
+STATIC_ROOT = os.path.join(BASE_DIR, 'static')
+
+# URL prefix for static files.
+# Example: "http://media.lawrence.com/static/"
+STATIC_URL = '/static/'
+
+# URL prefix for admin static files -- CSS, JavaScript and images.
+# Make sure to use a trailing slash.
+# Examples: "http://foo.com/static/admin/", "/static/admin/".
+ADMIN_MEDIA_PREFIX = '/static/admin/'
+
+# Additional locations of static files
+STATICFILES_DIRS = (
+	# Put strings here, like "/home/html/static" or "C:/www/django/static".
+	# Always use forward slashes, even on Windows.
+	# Don't forget to use absolute paths, not relative paths.
+)
+
+# 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',
+#	'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'eh$@nrqeyr8_&&ffk&%u6%c#(sb%rqcd0_%1m#a*@w8kj5sygw'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+	'leaves.loaders.ThemeLoader',
+	'django.template.loaders.filesystem.Loader',
+	'django.template.loaders.app_directories.Loader',
+)
+
+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.contrib.messages.context_processors.messages',
+	'leaves.utils.context_processor',
+)
+
+MIDDLEWARE_CLASSES = (
+	'leaves.middleware.LeavesSiteMiddleware',
+	'django.middleware.common.CommonMiddleware',
+	'django.contrib.sessions.middleware.SessionMiddleware',
+	'django.middleware.csrf.CsrfViewMiddleware',
+	'django.contrib.auth.middleware.AuthenticationMiddleware',
+	'django.contrib.messages.middleware.MessageMiddleware',
+	'django.middleware.locale.LocaleMiddleware',
+	'leaves.middleware.LeavesFallbackMiddleware',
+)
+
+ROOT_URLCONF = 'leaves.urls'
+
+# Python dotted path to the WSGI application used by Django's runserver.
+WSGI_APPLICATION = 'leaves.wsgi.application'
+
+TEMPLATE_DIRS = (
+	# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+	# Always use forward slashes, even on Windows.
+	# Don't forget to use absolute paths, not relative paths.
+)
+
+CACHES = {
+	'default': {
+		'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+	}
+}
+
+INSTALLED_APPS = (
+	'django.contrib.auth',
+	'django.contrib.contenttypes',
+	'django.contrib.sessions',
+	'django.contrib.sites',
+	'django.contrib.messages',
+	'django.contrib.staticfiles',
+	'django.contrib.admin',
+	'django.contrib.sitemaps',
+	'leaves',
+)
+
+LEAVES_THEME_DIRS = (
+	os.path.join(BASE_DIR, 'leaves', 'themes'),
+	os.path.join(BASE_DIR, 'themes'),
+)
+
+LEAVES_PLUGINS = (
+	'leaves.plugins.pages',
+	'leaves.plugins.blog',
+	'leaves.plugins.photos',
+	'leaves.plugins.archive',
+	'leaves.plugins.twitter',
+)
+
+LEAVES_PROXIES = None
+LEAVES_ENABLE_TRANSLATION = False
+LEAVES_HOMEPAGE_VIEW = 'leaves.views.leaf_stream'
+LEAVES_DEFAULT_COMMENT_STATUS = 'pending'
+
+INSTALLED_APPS += LEAVES_PLUGINS
+
+AVAILABLE_THEMES = []
+_static_dirs = []
+for parent in LEAVES_THEME_DIRS:
+	if not os.path.isdir(parent):
+		continue
+	for name in os.listdir(parent):
+		path = os.path.join(parent, name)
+		if os.path.isdir(path):
+			_static_dirs.append(os.path.join(path, 'static'))
+			AVAILABLE_THEMES.append((name, name.capitalize()))
+STATICFILES_DIRS += tuple(_static_dirs)
+
+# 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,
+        },
+    }
+}
+
+try:
+	_this_dir = os.path.normpath(os.path.dirname(__file__))
+	execfile(os.path.join(_this_dir, 'local_settings.py'))
+except:
+	pass
-from django.conf.urls.defaults import *
+from django.conf.urls import patterns, include, url
 from django.conf import settings
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+from django.contrib import admin
 from leaves.feeds import *
 from leaves.sitemaps import LeavesSitemap
 
+admin.autodiscover()
+
 sitemaps = {'leaves': LeavesSitemap}
 
 urlpatterns = patterns('leaves.views',
 	url(r'^author/(?P<username>[\w-]+)/$', 'view_author', name='view-author'),
 	url(r'^leaf/(?P<leaf_id>\d+)/$', 'view_leaf', name='view-leaf'),
 	url(r'^files/(?P<attachment_id>\d+)/(?P<filename>[^/]*)/?$', 'view_attachment', name='view-attachment'),
+	url(r'^admin/', include(admin.site.urls)),
 )
 
+urlpatterns += staticfiles_urlpatterns()
+
 urlpatterns += patterns('',
 	url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
 )
+"""
+WSGI config for demo 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", "leaves.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)
 #!/usr/bin/env python
-from django.core.management import execute_manager
-import imp
-try:
-	imp.find_module('settings') # Assumed to be in the same directory.
-except ImportError:
-	import sys
-	sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
-	sys.exit(1)
-
-import settings
+import os
+import sys
 
 if __name__ == "__main__":
-	execute_manager(settings)
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "leaves.settings")
+    from django.core.management import execute_from_command_line
+    execute_from_command_line(sys.argv)

settings.py

-import os
-
-DEBUG = True
-TEMPLATE_DEBUG = DEBUG
-
-BASE_DIR = os.path.normpath(os.path.dirname(__file__))
-
-ADMINS = (
-	# ('Your Name', 'your_email@example.com'),
-)
-
-MANAGERS = ADMINS
-
-DATABASES = {
-	'default': {
-		'ENGINE': 'django.db.backends.sqlite3',		 # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-		'NAME': os.path.join(BASE_DIR, 'leaves.db'), # Or path to database file if using sqlite3.
-		'USER': '',									 # Not used with sqlite3.
-		'PASSWORD': '',								 # Not used with sqlite3.
-		'HOST': '',									 # Set to empty string for localhost. Not used with sqlite3.
-		'PORT': '',									 # Set to empty string for default. Not used with sqlite3.
-	}
-}
-
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be available on all operating systems.
-# On Unix systems, a value of None will cause Django to use the same
-# timezone as the operating system.
-# If running in a Windows environment this must be set to the same as your
-# system time zone.
-TIME_ZONE = 'America/Chicago'
-
-# Support some of the more "common" languages by default.
-gettext_noop = lambda s: s
-LANGUAGES = (
-	('de', gettext_noop('German')),
-	('el', gettext_noop('Greek')),
-	('en', gettext_noop('English')),
-	('es', gettext_noop('Spanish')),
-	('fr', gettext_noop('French')),
-	('it', gettext_noop('Italian')),
-	('ja', gettext_noop('Japanese')),
-	('no', gettext_noop('Norwegian')),
-	('ko', gettext_noop('Korean')),
-	('pl', gettext_noop('Polish')),
-	('pt', gettext_noop('Portuguese')),
-	('ru', gettext_noop('Russian')),
-	('sv', gettext_noop('Swedish')),
-	('vi', gettext_noop('Vietnamese')),
-	('zh-cn', gettext_noop('Simplified Chinese')),
-	('zh-tw', gettext_noop('Traditional Chinese')),
-)
-
-# 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
-
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
-USE_I18N = True
-
-# If you set this to False, Django will not format dates, numbers and
-# calendars according to the current locale
-USE_L10N = True
-
-# Absolute filesystem path to the directory that will hold user-uploaded files.
-# Example: "/home/media/media.lawrence.com/media/"
-MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
-
-# URL that handles the media served from MEDIA_ROOT. Make sure to use a
-# trailing slash.
-# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
-MEDIA_URL = '/media/'
-
-# Absolute path to the directory static files should be collected to.
-# Don't put anything in this directory yourself; store your static files
-# in apps' "static/" subdirectories and in STATICFILES_DIRS.
-# Example: "/home/media/media.lawrence.com/static/"
-STATIC_ROOT = os.path.join(BASE_DIR, 'static')
-
-# URL prefix for static files.
-# Example: "http://media.lawrence.com/static/"
-STATIC_URL = '/static/'
-
-# URL prefix for admin static files -- CSS, JavaScript and images.
-# Make sure to use a trailing slash.
-# Examples: "http://foo.com/static/admin/", "/static/admin/".
-ADMIN_MEDIA_PREFIX = '/static/admin/'
-
-# Additional locations of static files
-STATICFILES_DIRS = (
-	# Put strings here, like "/home/html/static" or "C:/www/django/static".
-	# Always use forward slashes, even on Windows.
-	# Don't forget to use absolute paths, not relative paths.
-)
-
-# 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',
-#	'django.contrib.staticfiles.finders.DefaultStorageFinder',
-)
-
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = 'eh$@nrqeyr8_&&ffk&%u6%c#(sb%rqcd0_%1m#a*@w8kj5sygw'
-
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
-	'leaves.loaders.ThemeLoader',
-	'django.template.loaders.filesystem.Loader',
-	'django.template.loaders.app_directories.Loader',
-)
-
-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.contrib.messages.context_processors.messages',
-	'leaves.utils.context_processor',
-)
-
-MIDDLEWARE_CLASSES = (
-	'leaves.middleware.LeavesSiteMiddleware',
-	'django.middleware.common.CommonMiddleware',
-	'django.contrib.sessions.middleware.SessionMiddleware',
-	'django.middleware.csrf.CsrfViewMiddleware',
-	'django.contrib.auth.middleware.AuthenticationMiddleware',
-	'django.contrib.messages.middleware.MessageMiddleware',
-	'django.middleware.locale.LocaleMiddleware',
-	'leaves.middleware.LeavesFallbackMiddleware',
-)
-
-ROOT_URLCONF = 'urls'
-
-TEMPLATE_DIRS = (
-	# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
-	# Always use forward slashes, even on Windows.
-	# Don't forget to use absolute paths, not relative paths.
-)
-
-INSTALLED_APPS = (
-	'django.contrib.auth',
-	'django.contrib.contenttypes',
-	'django.contrib.sessions',
-	'django.contrib.sites',
-	'django.contrib.messages',
-	'django.contrib.staticfiles',
-	'django.contrib.admin',
-	'django.contrib.sitemaps',
-	'leaves',
-)
-
-LEAVES_THEME_DIRS = (
-	os.path.join(BASE_DIR, 'leaves', 'themes'),
-	os.path.join(BASE_DIR, 'themes'),
-)
-
-LEAVES_PLUGINS = (
-	'leaves.plugins.pages',
-	'leaves.plugins.blog',
-	'leaves.plugins.photos',
-	'leaves.plugins.archive',
-	'leaves.plugins.twitter',
-)
-
-LEAVES_PROXIES = None
-LEAVES_ENABLE_TRANSLATION = False
-LEAVES_HOMEPAGE_VIEW = 'leaves.views.leaf_stream'
-LEAVES_DEFAULT_COMMENT_STATUS = 'pending'
-
-INSTALLED_APPS += LEAVES_PLUGINS
-
-AVAILABLE_THEMES = []
-_static_dirs = []
-for parent in LEAVES_THEME_DIRS:
-	if not os.path.isdir(parent):
-		continue
-	for name in os.listdir(parent):
-		path = os.path.join(parent, name)
-		if os.path.isdir(path):
-			_static_dirs.append(os.path.join(path, 'static'))
-			AVAILABLE_THEMES.append((name, name.capitalize()))
-STATICFILES_DIRS += tuple(_static_dirs)
-
-# 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.
-# 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,
-	'handlers': {
-		'mail_admins': {
-			'level': 'ERROR',
-			'class': 'django.utils.log.AdminEmailHandler'
-		}
-	},
-	'loggers': {
-		'django.request': {
-			'handlers': ['mail_admins'],
-			'level': 'ERROR',
-			'propagate': True,
-		},
-	}
-}
-
-try:
-	_this_dir = os.path.normpath(os.path.dirname(__file__))
-	execfile(os.path.join(_this_dir, 'local_settings.py'))
-except:
-	pass

urls.py

-from django.conf.urls.defaults import patterns, include, url
-from django.contrib.staticfiles.urls import staticfiles_urlpatterns
-from django.contrib import admin
-from django.conf import settings
-
-admin.autodiscover()
-
-urlpatterns = patterns('',
-	url(r'^', include('leaves.urls')),
-	url(r'^admin/', include(admin.site.urls)),
-)
-
-urlpatterns += staticfiles_urlpatterns()