您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

settings.py 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. import os
  2. # Django settings for oscar project.
  3. PROJECT_DIR = os.path.dirname(__file__)
  4. location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
  5. DEBUG = True
  6. TEMPLATE_DEBUG = True
  7. SQL_DEBUG = True
  8. SEND_BROKEN_LINK_EMAILS = True
  9. ADMINS = (
  10. ('David', 'david.winterbottom@tangentlabs.co.uk'),
  11. )
  12. EMAIL_SUBJECT_PREFIX = '[Oscar sandbox] '
  13. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  14. MANAGERS = ADMINS
  15. DATABASES = {
  16. 'default': {
  17. 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
  18. 'NAME': os.path.join(os.path.dirname(__file__), 'db.sqlite'), # Or path to database file if using sqlite3.
  19. 'USER': '', # Not used with sqlite3.
  20. 'PASSWORD': '', # Not used with sqlite3.
  21. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
  22. 'PORT': '', # Set to empty string for default. Not used with sqlite3.
  23. }
  24. }
  25. CACHES = {
  26. 'default': {
  27. 'BACKEND':
  28. 'django.core.cache.backends.memcached.MemcachedCache',
  29. 'LOCATION': '127.0.0.1:11211',
  30. }
  31. }
  32. # Local time zone for this installation. Choices can be found here:
  33. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  34. # although not all choices may be available on all operating systems.
  35. # On Unix systems, a value of None will cause Django to use the same
  36. # timezone as the operating system.
  37. # If running in a Windows environment this must be set to the same as your
  38. # system time zone.
  39. TIME_ZONE = 'Europe/London'
  40. # Language code for this installation. All choices can be found here:
  41. # http://www.i18nguy.com/unicode/language-identifiers.html
  42. LANGUAGE_CODE = 'en-us'
  43. LANGUAGES = (
  44. ('de', 'German'),
  45. ('fr', 'French'),
  46. )
  47. ROSETTA_STORAGE_CLASS = 'rosetta.storage.SessionRosettaStorage'
  48. ROSETTA_ENABLE_TRANSLATION_SUGGESTIONS = True
  49. SITE_ID = 1
  50. # If you set this to False, Django will make some optimizations so as not
  51. # to load the internationalization machinery.
  52. USE_I18N = True
  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. # Absolute path to the directory that holds media.
  57. # Example: "/home/media/media.lawrence.com/"
  58. MEDIA_ROOT = location("assets/media")
  59. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  60. # trailing slash if there is a path component (optional in other cases).
  61. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  62. MEDIA_URL = '/media/'
  63. # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
  64. # trailing slash.
  65. # Examples: "http://foo.com/media/", "/media/".
  66. #ADMIN_MEDIA_PREFIX = '/media/admin/'
  67. STATIC_URL = '/static/'
  68. STATICFILES_DIRS = ()
  69. STATIC_ROOT = location('public/static')
  70. # Make this unique, and don't share it with anybody.
  71. SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  72. # List of callables that know how to import templates from various sources.
  73. TEMPLATE_LOADERS = (
  74. 'django.template.loaders.filesystem.Loader',
  75. 'django.template.loaders.app_directories.Loader',
  76. # 'django.template.loaders.eggs.Loader',
  77. )
  78. TEMPLATE_CONTEXT_PROCESSORS = (
  79. "django.contrib.auth.context_processors.auth",
  80. "django.core.context_processors.request",
  81. "django.core.context_processors.debug",
  82. "django.core.context_processors.i18n",
  83. "django.core.context_processors.media",
  84. "django.core.context_processors.static",
  85. "django.contrib.messages.context_processors.messages",
  86. # Oscar specific
  87. 'oscar.apps.search.context_processors.search_form',
  88. 'oscar.apps.promotions.context_processors.promotions',
  89. 'oscar.apps.checkout.context_processors.checkout',
  90. 'oscar.core.context_processors.metadata',
  91. )
  92. MIDDLEWARE_CLASSES = (
  93. 'django.middleware.common.CommonMiddleware',
  94. 'django.contrib.sessions.middleware.SessionMiddleware',
  95. 'django.middleware.csrf.CsrfViewMiddleware',
  96. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  97. 'django.contrib.messages.middleware.MessageMiddleware',
  98. 'django.middleware.transaction.TransactionMiddleware',
  99. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  100. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  101. 'oscar.apps.basket.middleware.BasketMiddleware',
  102. )
  103. INTERNAL_IPS = ('127.0.0.1',)
  104. ROOT_URLCONF = 'urls'
  105. from oscar import OSCAR_MAIN_TEMPLATE_DIR
  106. TEMPLATE_DIRS = (
  107. location('templates'),
  108. OSCAR_MAIN_TEMPLATE_DIR,
  109. )
  110. # A sample logging configuration. The only tangible logging
  111. # performed by this configuration is to send an email to
  112. # the site admins on every HTTP 500 error.
  113. # See http://docs.djangoproject.com/en/dev/topics/logging for
  114. # more details on how to customize your logging configuration.
  115. LOGGING = {
  116. 'version': 1,
  117. 'disable_existing_loggers': False,
  118. 'formatters': {
  119. 'verbose': {
  120. 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
  121. },
  122. 'simple': {
  123. 'format': '%(levelname)s %(message)s'
  124. },
  125. },
  126. 'handlers': {
  127. 'null': {
  128. 'level':'DEBUG',
  129. 'class':'django.utils.log.NullHandler',
  130. },
  131. 'console':{
  132. 'level':'DEBUG',
  133. 'class':'logging.StreamHandler',
  134. 'formatter': 'verbose'
  135. },
  136. 'checkout_file': {
  137. 'level': 'INFO',
  138. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  139. 'filename': 'checkout.log',
  140. 'formatter': 'verbose'
  141. },
  142. 'error_file': {
  143. 'level': 'INFO',
  144. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  145. 'filename': 'errors.log',
  146. 'formatter': 'verbose'
  147. },
  148. 'mail_admins': {
  149. 'level': 'ERROR',
  150. 'class': 'django.utils.log.AdminEmailHandler',
  151. },
  152. },
  153. 'loggers': {
  154. 'django': {
  155. 'handlers':['null'],
  156. 'propagate': True,
  157. 'level':'INFO',
  158. },
  159. 'django.request': {
  160. 'handlers': ['mail_admins', 'error_file'],
  161. 'level': 'ERROR',
  162. 'propagate': False,
  163. },
  164. 'oscar.checkout': {
  165. 'handlers': ['console', 'checkout_file'],
  166. 'propagate': True,
  167. 'level':'INFO',
  168. },
  169. 'django.db.backends': {
  170. 'handlers':['null'],
  171. 'propagate': False,
  172. 'level':'DEBUG',
  173. },
  174. }
  175. }
  176. INSTALLED_APPS = [
  177. 'django.contrib.auth',
  178. 'django.contrib.contenttypes',
  179. 'django.contrib.sessions',
  180. 'django.contrib.sites',
  181. 'django.contrib.messages',
  182. 'django.contrib.admin',
  183. 'django.contrib.flatpages',
  184. 'django.contrib.staticfiles',
  185. # External apps
  186. 'django_extensions',
  187. 'haystack',
  188. 'debug_toolbar',
  189. 'south',
  190. 'rosetta',
  191. # For profile testing
  192. 'apps.user',
  193. ]
  194. from oscar import get_core_apps
  195. INSTALLED_APPS = INSTALLED_APPS + get_core_apps(['apps.shipping'])
  196. AUTHENTICATION_BACKENDS = (
  197. 'oscar.apps.customer.auth_backends.Emailbackend',
  198. 'django.contrib.auth.backends.ModelBackend',
  199. )
  200. LOGIN_REDIRECT_URL = '/accounts/'
  201. APPEND_SLASH = True
  202. # Haystack settings
  203. HAYSTACK_CONNECTIONS = {
  204. 'default': {
  205. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  206. 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
  207. },
  208. }
  209. DEBUG_TOOLBAR_CONFIG = {
  210. 'INTERCEPT_REDIRECTS': False
  211. }
  212. AUTH_PROFILE_MODULE = 'user.Profile'
  213. # Oscar settings
  214. from oscar.defaults import *
  215. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  216. OSCAR_ALLOW_ANON_CHECKOUT = True
  217. OSCAR_INITIAL_ORDER_STATUS = 'Pending'
  218. OSCAR_INITIAL_LINE_STATUS = 'Pending'
  219. OSCAR_ORDER_STATUS_PIPELINE = {
  220. 'Pending': ('Being processed', 'Cancelled',),
  221. 'Being processed': ('Processed', 'Cancelled',),
  222. 'Cancelled': (),
  223. }
  224. OSCAR_SHOP_NAME = 'Oscar Sandbox'
  225. OSCAR_SHOP_TAGLINE = 'e-Commerce for Django'
  226. GOOGLE_ANALYTICS_ID = 'UA-XXXXX-Y'
  227. LOG_ROOT = location('logs')
  228. DISPLAY_VERSION = False
  229. THUMBNAIL_DEBUG = True
  230. # Must be within MEDIA_ROOT for sorl to work
  231. OSCAR_MISSING_IMAGE_URL = 'image_not_found.jpg'
  232. try:
  233. from settings_local import *
  234. except ImportError:
  235. pass