Skip to content

Commit

Permalink
Update test project layout and settings for Django 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
yumike committed Apr 23, 2012
1 parent e36a40b commit 1b574ae
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
*.pyo *.pyo
build/ build/
dist/ dist/
test_project/public/ test_project/project/public/
test_project/sqlite.db test_project/project/sqlite.db
18 changes: 7 additions & 11 deletions test_project/manage.py
100755 → 100644
Original file line number Original file line Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python
from django.core.management import execute_manager import os
import imp import sys
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


if __name__ == "__main__": 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)
File renamed without changes.
29 changes: 19 additions & 10 deletions test_project/settings.py → test_project/project/settings.py
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,4 @@
# Django settings for project project.
import os import os




Expand Down Expand Up @@ -39,9 +40,12 @@
USE_I18N = True USE_I18N = True


# If you set this to False, Django will not format dates, numbers and # 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 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. # Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/" # Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'public', 'media') MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'public', 'media')
Expand All @@ -61,11 +65,6 @@
# Example: "http://media.lawrence.com/static/" # Example: "http://media.lawrence.com/static/"
STATIC_URL = '/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 # Additional locations of static files
STATICFILES_DIRS = ( STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static". # Put strings here, like "/home/html/static" or "C:/www/django/static".
Expand All @@ -82,7 +81,7 @@
) )


# Make this unique, and don't share it with anybody. # 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. # List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = ( TEMPLATE_LOADERS = (
Expand All @@ -92,11 +91,12 @@
) )


TEMPLATE_CONTEXT_PROCESSORS = ( TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.debug', 'django.core.context_processors.debug',
'django.core.context_processors.i18n', 'django.core.context_processors.i18n',
'django.core.context_processors.media', 'django.core.context_processors.media',
'django.core.context_processors.static', 'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'lemon.metatags.context_processors.metatags', 'lemon.metatags.context_processors.metatags',
'lemon.utils.context_processors.site', 'lemon.utils.context_processors.site',
Expand All @@ -112,7 +112,10 @@
'lemon.pages.middleware.PageMiddleware' '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 = ( TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'), os.path.join(PROJECT_ROOT, 'templates'),
Expand Down Expand Up @@ -143,15 +146,21 @@


# A sample logging configuration. The only tangible logging # A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to # 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 # See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration. # more details on how to customize your logging configuration.
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': False, 'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': { 'handlers': {
'mail_admins': { 'mail_admins': {
'level': 'ERROR', 'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler' 'class': 'django.utils.log.AdminEmailHandler'
} }
}, },
Expand Down
6 changes: 3 additions & 3 deletions test_project/urls.py → test_project/project/urls.py
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,12 @@
from django.conf import settings 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.conf.urls.static import static
from django.contrib import admin


from lemon import extradmin from lemon import extradmin
from lemon.utils import urls




extradmin.autodiscover() admin.autodiscover()
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^admin/', include(extradmin.site.urls)), url(r'^admin/', include(extradmin.site.urls)),
url(r'^robots\.txt', include('lemon.robots.urls')), url(r'^robots\.txt', include('lemon.robots.urls')),
Expand Down
28 changes: 28 additions & 0 deletions test_project/project/wsgi.py
Original file line number Original file line Diff line number Diff line change
@@ -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.