Permalink
Browse files

Update test project layout and settings for Django 1.4

  • Loading branch information...
1 parent e36a40b commit 1b574ae5ded751a668b1384f976cad7d21ff81c6 @yumike yumike committed Apr 23, 2012
View
4 .gitignore
@@ -3,5 +3,5 @@
*.pyo
build/
dist/
-test_project/public/
-test_project/sqlite.db
+test_project/project/public/
+test_project/project/sqlite.db
View
18 test_project/manage.py 100755 → 100644
@@ -1,14 +1,10 @@
#!/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", "project.settings")
+
+ from django.core.management import execute_from_command_line
+
+ execute_from_command_line(sys.argv)
View
0 test_project/__init__.py → test_project/project/__init__.py
File renamed without changes.
View
29 test_project/settings.py → test_project/project/settings.py
@@ -1,3 +1,4 @@
+# Django settings for project project.
import os
@@ -39,9 +40,12 @@
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
-# calendars according to the current locale
+# 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(PROJECT_ROOT, 'public', 'media')
@@ -61,11 +65,6 @@
# 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".
@@ -82,7 +81,7 @@
)
# Make this unique, and don't share it with anybody.
-SECRET_KEY = 'nd9m2j@6_8j%5=ew5+fa3@-&=21tyx$#_@y_@hp7y-@ny$@xqn'
+SECRET_KEY = 'v-7hqe%vz%_kk7l0vbpbq6oy$e2zzj!+!y^6jidqt1w85$z4-h'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
@@ -92,11 +91,12 @@
)
TEMPLATE_CONTEXT_PROCESSORS = (
- 'django.core.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.tz',
+ 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'lemon.metatags.context_processors.metatags',
'lemon.utils.context_processors.site',
@@ -112,7 +112,10 @@
'lemon.pages.middleware.PageMiddleware'
)
-ROOT_URLCONF = 'test_project.urls'
+ROOT_URLCONF = 'project.urls'
+
+# Python dotted path to the WSGI application used by Django's runserver.
+WSGI_APPLICATION = 'project.wsgi.application'
TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'),
@@ -143,15 +146,21 @@
# 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.
+# 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'
}
},
View
6 test_project/urls.py → test_project/project/urls.py
@@ -1,12 +1,12 @@
from django.conf import settings
-from django.conf.urls.defaults import include, patterns, url
+from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
+from django.contrib import admin
from lemon import extradmin
-from lemon.utils import urls
-extradmin.autodiscover()
+admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(extradmin.site.urls)),
url(r'^robots\.txt', include('lemon.robots.urls')),
View
28 test_project/project/wsgi.py
@@ -0,0 +1,28 @@
+"""
+WSGI config for project 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.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)

0 comments on commit 1b574ae

Please sign in to comment.