Skip to content

Commit e67ab87

Browse files
committed
Django v1.4
1 parent 0832edd commit e67ab87

File tree

5 files changed

+53
-24
lines changed

5 files changed

+53
-24
lines changed

project/manage.py

100644100755
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#!/usr/bin/env python
2-
from django.core.management import execute_manager
3-
import imp
4-
try:
5-
imp.find_module('settings') # Assumed to be in the same directory.
6-
except ImportError:
7-
import sys
8-
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__)
9-
sys.exit(1)
10-
11-
import settings
2+
import os
3+
import sys
124

135
if __name__ == "__main__":
14-
execute_manager(settings)
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
7+
8+
from django.core.management import execute_from_command_line
9+
10+
execute_from_command_line(sys.argv)
File renamed without changes.

project/settings.py renamed to project/project/settings.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
DATABASES = {
1313
'default': {
14-
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
14+
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
1515
'NAME': '', # Or path to database file if using sqlite3.
1616
'USER': '', # Not used with sqlite3.
1717
'PASSWORD': '', # Not used with sqlite3.
@@ -20,10 +20,6 @@
2020
}
2121
}
2222

23-
# Hosts/domain names that are valid for this site; required if DEBUG is False
24-
# See https://docs.djangoproject.com/en/1.3/ref/settings/#allowed-hosts
25-
ALLOWED_HOSTS = []
26-
2723
# Local time zone for this installation. Choices can be found here:
2824
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
2925
# although not all choices may be available on all operating systems.
@@ -44,9 +40,12 @@
4440
USE_I18N = True
4541

4642
# If you set this to False, Django will not format dates, numbers and
47-
# calendars according to the current locale
43+
# calendars according to the current locale.
4844
USE_L10N = True
4945

46+
# If you set this to False, Django will not use timezone-aware datetimes.
47+
USE_TZ = True
48+
5049
# Absolute filesystem path to the directory that will hold user-uploaded files.
5150
# Example: "/home/media/media.lawrence.com/media/"
5251
MEDIA_ROOT = ''
@@ -66,11 +65,6 @@
6665
# Example: "http://media.lawrence.com/static/"
6766
STATIC_URL = '/static/'
6867

69-
# URL prefix for admin static files -- CSS, JavaScript and images.
70-
# Make sure to use a trailing slash.
71-
# Examples: "http://foo.com/static/admin/", "/static/admin/".
72-
ADMIN_MEDIA_PREFIX = '/static/admin/'
73-
7468
# Additional locations of static files
7569
STATICFILES_DIRS = (
7670
# Put strings here, like "/home/html/static" or "C:/www/django/static".
@@ -102,10 +96,15 @@
10296
'django.middleware.csrf.CsrfViewMiddleware',
10397
'django.contrib.auth.middleware.AuthenticationMiddleware',
10498
'django.contrib.messages.middleware.MessageMiddleware',
99+
# Uncomment the next line for simple clickjacking protection:
100+
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
105101
)
106102

107103
ROOT_URLCONF = 'project.urls'
108104

105+
# Python dotted path to the WSGI application used by Django's runserver.
106+
WSGI_APPLICATION = 'project.wsgi.application'
107+
109108
TEMPLATE_DIRS = (
110109
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
111110
# Always use forward slashes, even on Windows.
@@ -127,15 +126,21 @@
127126

128127
# A sample logging configuration. The only tangible logging
129128
# performed by this configuration is to send an email to
130-
# the site admins on every HTTP 500 error.
129+
# the site admins on every HTTP 500 error when DEBUG=False.
131130
# See http://docs.djangoproject.com/en/dev/topics/logging for
132131
# more details on how to customize your logging configuration.
133132
LOGGING = {
134133
'version': 1,
135134
'disable_existing_loggers': False,
135+
'filters': {
136+
'require_debug_false': {
137+
'()': 'django.utils.log.RequireDebugFalse'
138+
}
139+
},
136140
'handlers': {
137141
'mail_admins': {
138142
'level': 'ERROR',
143+
'filters': ['require_debug_false'],
139144
'class': 'django.utils.log.AdminEmailHandler'
140145
}
141146
},

project/urls.py renamed to project/project/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.conf.urls.defaults import patterns, include, url
1+
from django.conf.urls import patterns, include, url
22

33
# Uncomment the next two lines to enable the admin:
44
# from django.contrib import admin

project/project/wsgi.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
WSGI config for project project.
3+
4+
This module contains the WSGI application used by Django's development server
5+
and any production WSGI deployments. It should expose a module-level variable
6+
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
7+
this application via the ``WSGI_APPLICATION`` setting.
8+
9+
Usually you will have the standard Django WSGI application here, but it also
10+
might make sense to replace the whole Django WSGI application with a custom one
11+
that later delegates to the Django one. For example, you could introduce WSGI
12+
middleware here, or combine a Django application with an application of another
13+
framework.
14+
15+
"""
16+
import os
17+
18+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
19+
20+
# This application object is used by any WSGI server configured to use this
21+
# file. This includes Django's development server, if the WSGI_APPLICATION
22+
# setting points here.
23+
from django.core.wsgi import get_wsgi_application
24+
application = get_wsgi_application()
25+
26+
# Apply WSGI middleware here.
27+
# from helloworld.wsgi import HelloWorldApplication
28+
# application = HelloWorldApplication(application)

0 commit comments

Comments
 (0)