unordinary

Django setting,urls.py

Jun 13th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.09 KB | None | 0 0
  1. =================================================settings.py==================================
  2.  
  3. # Django settings for homepage project.
  4. import os
  5. gettext = lambda s: s
  6. PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
  7.  
  8. DEBUG = True
  9. TEMPLATE_DEBUG = DEBUG
  10.  
  11. ADMINS = (
  12.     # ('Your Name', '[email protected]'),
  13. )
  14.  
  15. MANAGERS = ADMINS
  16.  
  17. DATABASES = {
  18.     'default': {
  19.         'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
  20.         'NAME': os.path.join(PROJECT_PATH, 'database.sqlite'),                     # Or path to database file if using sqlite3.
  21.         'USER': '',                      # Not used with sqlite3.
  22.         'PASSWORD': '',                  # Not used with sqlite3.
  23.         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
  24.         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
  25.     }
  26. }
  27.  
  28. # Local time zone for this installation. Choices can be found here:
  29. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  30. # although not all choices may be available on all operating systems.
  31. # On Unix systems, a value of None will cause Django to use the same
  32. # timezone as the operating system.
  33. # If running in a Windows environment this must be set to the same as your
  34. # system time zone.
  35. TIME_ZONE = 'America/Chicago'
  36.  
  37. # Language code for this installation. All choices can be found here:
  38. # http://www.i18nguy.com/unicode/language-identifiers.html
  39. LANGUAGE_CODE = 'en-us'
  40.  
  41. LANGUAGES = (
  42.     ('en', gettext('English')),
  43.     ('de', gettext('German')),
  44.     ('ru', gettext('Russian')),
  45.     )
  46.  
  47. SITE_ID = 1
  48.  
  49. # If you set this to False, Django will make some optimizations so as not
  50. # to load the internationalization machinery.
  51. USE_I18N = True
  52.  
  53. # If you set this to False, Django will not format dates, numbers and
  54. # calendars according to the current locale
  55. USE_L10N = True
  56.  
  57. # Absolute filesystem path to the directory that will hold user-uploaded files.
  58. # Example: "/home/media/media.lawrence.com/media/"
  59. MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
  60.  
  61. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  62. # trailing slash.
  63. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
  64. MEDIA_URL = 'media/'
  65.  
  66. # Absolute path to the directory static files should be collected to.
  67. # Don't put anything in this directory yourself; store your static files
  68. # in apps' "static/" subdirectories and in STATICFILES_DIRS.
  69. # Example: "/home/media/media.lawrence.com/static/"
  70. STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
  71.  
  72. # URL prefix for static files.
  73. # Example: "http://media.lawrence.com/static/"
  74. STATIC_URL = '/static/'
  75.  
  76. # URL prefix for admin static files -- CSS, JavaScript and images.
  77. # Make sure to use a trailing slash.
  78. # Examples: "http://foo.com/static/admin/", "/static/admin/".
  79. ADMIN_MEDIA_PREFIX = '/static/admin/'
  80.  
  81. # Additional locations of static files
  82. STATICFILES_DIRS = (
  83.     # Put strings here, like "/home/html/static" or "C:/www/django/static".
  84.     # Always use forward slashes, even on Windows.
  85.     # Don't forget to use absolute paths, not relative paths.
  86. )
  87.  
  88. # List of finder classes that know how to find static files in
  89. # various locations.
  90.  
  91. STATICFILES_FINDERS = (
  92.     'django.contrib.staticfiles.finders.FileSystemFinder',
  93.     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  94. #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
  95. )
  96.  
  97. # Make this unique, and don't share it with anybody.
  98. SECRET_KEY = '+7v9dxr&1o2i%_rd=mt)u%i&($wo03i3&=vp=g11x@a8^cr1!a'
  99.  
  100. # List of callables that know how to import templates from various sources.
  101. TEMPLATE_LOADERS = (
  102.     'django.template.loaders.filesystem.Loader',
  103.     'django.template.loaders.app_directories.Loader',
  104. #     'django.template.loaders.eggs.Loader',
  105. )
  106.  
  107. MIDDLEWARE_CLASSES = (
  108.     'django.middleware.common.CommonMiddleware',
  109.     'django.contrib.sessions.middleware.SessionMiddleware',
  110.     'django.middleware.csrf.CsrfViewMiddleware',
  111.     'django.contrib.auth.middleware.AuthenticationMiddleware',
  112.     'django.contrib.messages.middleware.MessageMiddleware',
  113.     'django.middleware.locale.LocaleMiddleware',
  114. )
  115.  
  116. ROOT_URLCONF = 'homepage.urls'
  117.  
  118. TEMPLATE_CONTEXT_PROCESSORS = (
  119.     'django.core.context_processors.debug',
  120.     'django.core.context_processors.i18n',
  121.     'django.core.context_processors.media',
  122.     'django.core.context_processors.static',
  123.     'django.contrib.auth.context_processors.auth',
  124.     'django.contrib.messages.context_processors.messages',
  125. )
  126.  
  127. TEMPLATE_DIRS = (
  128.     os.path.join(PROJECT_PATH, 'templates'),
  129.     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
  130.     # Always use forward slashes, even on Windows.
  131.     # Don't forget to use absolute paths, not relative paths.
  132. )
  133.  
  134. INSTALLED_APPS = (
  135.     'django.contrib.auth',
  136.     'django.contrib.contenttypes',
  137.     'django.contrib.sessions',
  138.     'django.contrib.sites',
  139.     'django.contrib.messages',
  140.     'django.contrib.staticfiles',
  141.     'homepage.projects',
  142.     # Uncomment the next line to enable the admin:
  143.     'django.contrib.admin',
  144.     # Uncomment the next line to enable admin documentation:
  145.     # 'django.contrib.admindocs',
  146. )
  147.  
  148. # A sample logging configuration. The only tangible logging
  149. # performed by this configuration is to send an email to
  150. # the site admins on every HTTP 500 error.
  151. # See http://docs.djangoproject.com/en/dev/topics/logging for
  152. # more details on how to customize your logging configuration.
  153. LOGGING = {
  154.     'version': 1,
  155.     'disable_existing_loggers': False,
  156.     'handlers': {
  157.         'mail_admins': {
  158.             'level': 'ERROR',
  159.             'class': 'django.utils.log.AdminEmailHandler'
  160.         }
  161.     },
  162.     'loggers': {
  163.         'django.request': {
  164.             'handlers': ['mail_admins'],
  165.             'level': 'ERROR',
  166.             'propagate': True,
  167.         },
  168.     }
  169. }
  170.  
  171.  
  172. =============================================urls.py====================================
  173.  
  174.  
  175. from django.conf.urls.defaults import patterns, include, url
  176. from django.conf import settings
  177. from homepage.views import home, contacts
  178. from homepage.projects import views
  179.  
  180. # Uncomment the next two lines to enable the admin:
  181. from django.contrib import admin
  182. admin.autodiscover()
  183.  
  184. urlpatterns = patterns('',
  185.     (r'^$', home),
  186.     ('^contacts/$', contacts),
  187.     ('^projects/$', views.view_projects),
  188.     (r'^i18n/', include('django.conf.urls.i18n')),
  189.     # Examples:
  190.     # url(r'^$', 'homepage.views.home', name='home'),
  191.     # url(r'^homepage/', include('homepage.foo.urls')),
  192.  
  193.     # Uncomment the admin/doc line below to enable admin documentation:
  194.     # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
  195.  
  196.     # Uncomment the next line to enable the admin:
  197.     url(r'^admin/', include(admin.site.urls)),
  198. )
  199.  
  200.  
  201. if settings.DEBUG:
  202.     urlpatterns = patterns('',
  203.     url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
  204.         {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
  205.     url(r'', include('django.contrib.staticfiles.urls')),
  206. ) + urlpatterns
Advertisement
Add Comment
Please, Sign In to add comment