diff options
| author | Aymeric Augustin | 2013-10-14 22:46:30 +0200 | 
|---|---|---|
| committer | Aymeric Augustin | 2013-10-14 23:30:04 +0200 | 
| commit | 10520905180387d0c51eb32907e53b79f4030190 (patch) | |
| tree | 9bda601f7d1f8e955021995ce4b7e391d6c69eb0 | |
| parent | 5dd6de619b7b4fa5212c79f60a59e6d207ca5c6a (diff) | |
| download | django-debug-toolbar-10520905180387d0c51eb32907e53b79f4030190.tar.bz2 | |
Update the example app with a modern project template.
| -rwxr-xr-x | example/manage.py | 15 | ||||
| -rw-r--r-- | example/settings.py | 116 | ||||
| -rw-r--r-- | example/urls.py | 12 | ||||
| -rw-r--r-- | example/wsgi.py | 7 | 
4 files changed, 68 insertions, 82 deletions
| diff --git a/example/manage.py b/example/manage.py index 5e78ea9..2605e37 100755 --- a/example/manage.py +++ b/example/manage.py @@ -1,11 +1,10 @@  #!/usr/bin/env python -from django.core.management import execute_manager -try: -    import 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(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) -    sys.exit(1) +import os +import sys  if __name__ == "__main__": -    execute_manager(settings) +    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") + +    from django.core.management import execute_from_command_line + +    execute_from_command_line(sys.argv) diff --git a/example/settings.py b/example/settings.py index 6fa3e56..4df22a0 100644 --- a/example/settings.py +++ b/example/settings.py @@ -1,42 +1,69 @@ +"""Django settings for example project.""" +  import os -PROJECT_PATH = os.path.realpath(os.path.dirname(__file__)) -os.sys.path.insert(0, os.path.dirname(PROJECT_PATH)) +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + + +# Quick-start development settings - unsuitable for production + +SECRET_KEY = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' -ADMIN_MEDIA_PREFIX = '/admin_media/' -DATABASE_ENGINE = 'sqlite3' -DATABASE_NAME = 'example.db'  DEBUG = True + +INTERNAL_IPS = ['127.0.0.1', '::1'] + +TEMPLATE_DEBUG = True + + +# Application definition +  INSTALLED_APPS = ( -    'django.contrib.auth',      'django.contrib.admin', +    'django.contrib.auth',      'django.contrib.contenttypes',      'django.contrib.sessions', -    'django.contrib.sites', +    'django.contrib.messages', +    'django.contrib.staticfiles',      'debug_toolbar',  ) -INTERNAL_IPS = ('127.0.0.1',) -MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media') -MEDIA_URL = '/media' -STATIC_ROOT = os.path.join(HOME_ROOT, 'staticfiles') -STATIC_URL = '/static/' +  MIDDLEWARE_CLASSES = ( -    'django.middleware.common.CommonMiddleware',      'django.contrib.sessions.middleware.SessionMiddleware', +    'django.middleware.common.CommonMiddleware', +    'django.middleware.csrf.CsrfViewMiddleware',      'django.contrib.auth.middleware.AuthenticationMiddleware', +    'django.contrib.messages.middleware.MessageMiddleware', +    'django.middleware.clickjacking.XFrameOptionsMiddleware',      'debug_toolbar.middleware.DebugToolbarMiddleware',  ) +  ROOT_URLCONF = 'example.urls' -SECRET_KEY = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcd' -SITE_ID = 1 -TEMPLATE_CONTEXT_PROCESSORS = ( -    'django.core.context_processors.auth', -    'django.core.context_processors.media', -    'django.core.context_processors.request', -) -TEMPLATE_DEBUG = DEBUG -TEMPLATE_DIRS = ( -        os.path.join(PROJECT_PATH, 'templates'), -      ) + +STATIC_URL = '/static/' + +TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'example', 'templates')] + +WSGI_APPLICATION = 'example.wsgi.application' + + +# Cache and database + +CACHES = { +    'default': { +        'BACKEND': 'django.core.cache.backends.dummy.DummyCache', +    } +} + +DATABASES = { +    'default': { +        'ENGINE': 'django.db.backends.sqlite3', +        'NAME': os.path.join(BASE_DIR, 'example', 'db.sqlite3'), +    } +} + + +# django-debug-toolbar +  DEBUG_TOOLBAR_PANELS = (      'debug_toolbar.panels.version.VersionDebugPanel',      'debug_toolbar.panels.timer.TimerDebugPanel', @@ -50,44 +77,3 @@ DEBUG_TOOLBAR_PANELS = (      'debug_toolbar.panels.signals.SignalDebugPanel',      'debug_toolbar.panels.logger.LoggingPanel',  ) - -CACHE_BACKEND = 'dummy://' -#CACHE_BACKEND = 'memcached://127.0.0.1:11211' -LOGGING = { -    'version': 1, -    'disable_existing_loggers': True, -    'formatters': { -        'verbose': { -            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' -        }, -    }, -    'handlers': { -        'null': { -            'level':'DEBUG', -            'class':'django.utils.log.NullHandler', -        }, -        'console':{ -            'level':'DEBUG', -            'class':'logging.StreamHandler', -            'formatter': 'verbose' -        }, -    }, -    'loggers': { -        'django': { -            'handlers':['null'], -            'propagate': True, -            'level':'INFO', -        }, -        'django.request': { -            'handlers': ['console'], -            'level': 'ERROR', -            'propagate': False, -        }, -        'django.db.backends': { -            'handlers': ['console'], -            'level': 'DEBUG', -            'propagate': False, -        }, -    } -} - diff --git a/example/urls.py b/example/urls.py index d8bed27..f5ad145 100644 --- a/example/urls.py +++ b/example/urls.py @@ -7,14 +7,8 @@ admin.autodiscover()  urlpatterns = patterns('',      (r'^$', TemplateView.as_view(template_name='index.html')), -    (r'^jquery/index/$', TemplateView.as_view(template_name='jquery/index.html')), -    (r'^mootools/index/$', TemplateView.as_view(template_name='mootools/index.html')), -    (r'^prototype/index/$', TemplateView.as_view(template_name='prototype/index.html')), +    (r'^jquery/$', TemplateView.as_view(template_name='jquery/index.html')), +    (r'^mootools/$', TemplateView.as_view(template_name='mootools/index.html')), +    (r'^prototype/$', TemplateView.as_view(template_name='prototype/index.html')),      (r'^admin/', include(admin.site.urls)),  ) - -if settings.DEBUG: -    urlpatterns += patterns('', -        (r'^media/(.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}) -    ) - diff --git a/example/wsgi.py b/example/wsgi.py new file mode 100644 index 0000000..f87faba --- /dev/null +++ b/example/wsgi.py @@ -0,0 +1,7 @@ +"""WSGI config for example project.""" + +import os +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") + +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() | 
