Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

settings.py 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. import os
  2. # Path helper
  3. location = lambda x: os.path.join(
  4. os.path.dirname(os.path.realpath(__file__)), x)
  5. USE_TZ = True
  6. DEBUG = True
  7. TEMPLATE_DEBUG = True
  8. SQL_DEBUG = True
  9. EMAIL_SUBJECT_PREFIX = '[Oscar US sandbox] '
  10. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  11. # Use a Sqlite database by default
  12. DATABASES = {
  13. 'default': {
  14. 'ENGINE': 'django.db.backends.sqlite3',
  15. 'NAME': location('db.sqlite'),
  16. 'USER': '',
  17. 'PASSWORD': '',
  18. 'HOST': '',
  19. 'PORT': '',
  20. 'ATOMIC_REQUESTS': True
  21. }
  22. }
  23. CACHES = {
  24. 'default': {
  25. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  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 = 'Europe/London'
  36. # Language code for this installation. All choices can be found here:
  37. # http://www.i18nguy.com/unicode/language-identifiers.html
  38. LANGUAGE_CODE = 'en-gb'
  39. # Includes all languages that have >50% coverage in Transifex
  40. # Taken from Django's default setting for LANGUAGES
  41. gettext_noop = lambda s: s
  42. LANGUAGES = (
  43. ('en-us', gettext_noop('American English')),
  44. )
  45. SITE_ID = 1
  46. # If you set this to False, Django will make some optimizations so as not
  47. # to load the internationalization machinery.
  48. USE_I18N = True
  49. # If you set this to False, Django will not format dates, numbers and
  50. # calendars according to the current locale
  51. USE_L10N = True
  52. # Absolute path to the directory that holds media.
  53. # Example: "/home/media/media.lawrence.com/"
  54. MEDIA_ROOT = location("public/media")
  55. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  56. # trailing slash if there is a path component (optional in other cases).
  57. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  58. MEDIA_URL = '/media/'
  59. # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
  60. # trailing slash.
  61. # Examples: "http://foo.com/media/", "/media/".
  62. #ADMIN_MEDIA_PREFIX = '/media/admin/'
  63. STATIC_URL = '/static/'
  64. STATIC_ROOT = location('public/static')
  65. STATICFILES_DIRS = (
  66. location('static/'),
  67. )
  68. STATICFILES_FINDERS = (
  69. 'django.contrib.staticfiles.finders.FileSystemFinder',
  70. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  71. 'compressor.finders.CompressorFinder',
  72. )
  73. # Make this unique, and don't share it with anybody.
  74. SECRET_KEY = '$)a6n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  75. # List of callables that know how to import templates from various sources.
  76. TEMPLATE_LOADERS = (
  77. 'django.template.loaders.filesystem.Loader',
  78. 'django.template.loaders.app_directories.Loader',
  79. # needed by django-treebeard for admin (and potentially other libs)
  80. 'django.template.loaders.eggs.Loader',
  81. )
  82. TEMPLATE_CONTEXT_PROCESSORS = (
  83. "django.contrib.auth.context_processors.auth",
  84. "django.core.context_processors.request",
  85. "django.core.context_processors.debug",
  86. "django.core.context_processors.i18n",
  87. "django.core.context_processors.media",
  88. "django.core.context_processors.static",
  89. "django.contrib.messages.context_processors.messages",
  90. # Oscar specific
  91. 'oscar.apps.search.context_processors.search_form',
  92. 'oscar.apps.promotions.context_processors.promotions',
  93. 'oscar.apps.checkout.context_processors.checkout',
  94. 'oscar.core.context_processors.metadata',
  95. 'oscar.apps.customer.notifications.context_processors.notifications',
  96. )
  97. MIDDLEWARE_CLASSES = (
  98. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  99. 'django.contrib.sessions.middleware.SessionMiddleware',
  100. 'django.middleware.csrf.CsrfViewMiddleware',
  101. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  102. 'django.contrib.messages.middleware.MessageMiddleware',
  103. 'django.middleware.transaction.TransactionMiddleware',
  104. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  105. # Allow languages to be selected
  106. 'django.middleware.locale.LocaleMiddleware',
  107. 'django.middleware.common.CommonMiddleware',
  108. # Ensure a valid basket is added to the request instance for every request
  109. 'oscar.apps.basket.middleware.BasketMiddleware',
  110. # Enable the ProfileMiddleware, then add ?cprofile to any
  111. # URL path to print out profile details
  112. #'oscar.profiling.middleware.ProfileMiddleware',
  113. )
  114. ROOT_URLCONF = 'urls'
  115. # Add another path to Oscar's templates. This allows templates to be
  116. # customised easily.
  117. from oscar import OSCAR_MAIN_TEMPLATE_DIR
  118. TEMPLATE_DIRS = (
  119. location('templates'),
  120. OSCAR_MAIN_TEMPLATE_DIR,
  121. )
  122. # A sample logging configuration. The only tangible logging
  123. # performed by this configuration is to send an email to
  124. # the site admins on every HTTP 500 error.
  125. # See http://docs.djangoproject.com/en/dev/topics/logging for
  126. # more details on how to customize your logging configuration.
  127. LOGGING = {
  128. 'version': 1,
  129. 'disable_existing_loggers': True,
  130. 'formatters': {
  131. 'verbose': {
  132. 'format': '%(levelname)s %(asctime)s %(module)s %(message)s',
  133. },
  134. 'simple': {
  135. 'format': '[%(asctime)s] %(message)s'
  136. },
  137. },
  138. 'filters': {
  139. 'require_debug_false': {
  140. '()': 'django.utils.log.RequireDebugFalse'
  141. }
  142. },
  143. 'handlers': {
  144. 'null': {
  145. 'level': 'DEBUG',
  146. 'class': 'django.utils.log.NullHandler',
  147. },
  148. 'console': {
  149. 'level': 'DEBUG',
  150. 'class': 'logging.StreamHandler',
  151. 'formatter': 'verbose'
  152. },
  153. 'checkout_file': {
  154. 'level': 'INFO',
  155. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  156. 'filename': 'checkout.log',
  157. 'formatter': 'verbose'
  158. },
  159. 'gateway_file': {
  160. 'level': 'INFO',
  161. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  162. 'filename': 'gateway.log',
  163. 'formatter': 'simple'
  164. },
  165. 'error_file': {
  166. 'level': 'INFO',
  167. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  168. 'filename': 'errors.log',
  169. 'formatter': 'verbose'
  170. },
  171. 'sorl_file': {
  172. 'level': 'INFO',
  173. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  174. 'filename': 'sorl.log',
  175. 'formatter': 'verbose'
  176. },
  177. 'mail_admins': {
  178. 'level': 'ERROR',
  179. 'class': 'django.utils.log.AdminEmailHandler',
  180. 'filters': ['require_debug_false'],
  181. },
  182. },
  183. 'loggers': {
  184. # Django loggers
  185. 'django': {
  186. 'handlers': ['null'],
  187. 'propagate': True,
  188. 'level': 'INFO',
  189. },
  190. 'django.request': {
  191. 'handlers': ['mail_admins', 'error_file'],
  192. 'level': 'ERROR',
  193. 'propagate': False,
  194. },
  195. 'django.db.backends': {
  196. 'handlers': ['null'],
  197. 'propagate': False,
  198. 'level': 'DEBUG',
  199. },
  200. # Oscar core loggers
  201. 'oscar.checkout': {
  202. 'handlers': ['console', 'checkout_file'],
  203. 'propagate': False,
  204. 'level': 'INFO',
  205. },
  206. 'oscar.catalogue.import': {
  207. 'handlers': ['console'],
  208. 'propagate': False,
  209. 'level': 'INFO',
  210. },
  211. 'oscar.alerts': {
  212. 'handlers': ['null'],
  213. 'propagate': False,
  214. 'level': 'INFO',
  215. },
  216. # Sandbox logging
  217. 'gateway': {
  218. 'handlers': ['gateway_file'],
  219. 'propagate': True,
  220. 'level': 'INFO',
  221. },
  222. # Third party
  223. 'south': {
  224. 'handlers': ['null'],
  225. 'propagate': True,
  226. 'level': 'INFO',
  227. },
  228. 'sorl.thumbnail': {
  229. 'handlers': ['sorl_file'],
  230. 'propagate': True,
  231. 'level': 'INFO',
  232. },
  233. # Suppress output of this debug toolbar panel
  234. 'template_timings_panel': {
  235. 'handlers': ['null'],
  236. 'level': 'DEBUG',
  237. 'propagate': False,
  238. }
  239. }
  240. }
  241. INSTALLED_APPS = [
  242. 'django.contrib.auth',
  243. 'django.contrib.contenttypes',
  244. 'django.contrib.sessions',
  245. 'django.contrib.sites',
  246. 'django.contrib.messages',
  247. 'django.contrib.admin',
  248. 'django.contrib.flatpages',
  249. 'django.contrib.staticfiles',
  250. 'django.contrib.sitemaps',
  251. 'django_extensions',
  252. # Debug toolbar + extensions
  253. 'debug_toolbar',
  254. 'template_timings_panel',
  255. 'south',
  256. 'compressor', # Oscar's templates use compressor
  257. ]
  258. from oscar import get_core_apps
  259. INSTALLED_APPS = INSTALLED_APPS + get_core_apps(
  260. ['apps.partner', 'apps.checkout', 'apps.shipping'])
  261. # Add Oscar's custom auth backend so users can sign in using their email
  262. # address.
  263. AUTHENTICATION_BACKENDS = (
  264. 'oscar.apps.customer.auth_backends.EmailBackend',
  265. 'django.contrib.auth.backends.ModelBackend',
  266. )
  267. LOGIN_REDIRECT_URL = '/'
  268. APPEND_SLASH = True
  269. # Haystack settings
  270. HAYSTACK_CONNECTIONS = {
  271. 'default': {
  272. 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  273. 'PATH': location('whoosh_index'),
  274. },
  275. }
  276. # =============
  277. # Debug Toolbar
  278. # =============
  279. # Implicit setup can often lead to problems with circular imports, so we
  280. # explicitly wire up the toolbar
  281. DEBUG_TOOLBAR_PATCH_SETTINGS = False
  282. DEBUG_TOOLBAR_PANELS = [
  283. 'debug_toolbar.panels.versions.VersionsPanel',
  284. 'debug_toolbar.panels.timer.TimerPanel',
  285. 'debug_toolbar.panels.settings.SettingsPanel',
  286. 'debug_toolbar.panels.headers.HeadersPanel',
  287. 'debug_toolbar.panels.request.RequestPanel',
  288. 'debug_toolbar.panels.sql.SQLPanel',
  289. 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
  290. 'debug_toolbar.panels.templates.TemplatesPanel',
  291. 'template_timings_panel.panels.TemplateTimings.TemplateTimings',
  292. 'debug_toolbar.panels.cache.CachePanel',
  293. 'debug_toolbar.panels.signals.SignalsPanel',
  294. 'debug_toolbar.panels.logging.LoggingPanel',
  295. 'debug_toolbar.panels.redirects.RedirectsPanel',
  296. ]
  297. INTERNAL_IPS = ['127.0.0.1', '::1']
  298. # ==============
  299. # Oscar settings
  300. # ==============
  301. from oscar.defaults import *
  302. # Meta
  303. # ====
  304. OSCAR_SHOP_TAGLINE = 'US Sandbox'
  305. OSCAR_DEFAULT_CURRENCY = 'USD'
  306. OSCAR_ALLOW_ANON_CHECKOUT = True
  307. # LESS/CSS/statics
  308. # ================
  309. # We default to using CSS files, rather than the LESS files that generate them.
  310. # If you want to develop Oscar's CSS, then set USE_LESS=True and
  311. # COMPRESS_ENABLED=False in your settings_local module and ensure you have
  312. # 'lessc' installed. You can do this by running:
  313. #
  314. # pip install -r requirements_less.txt
  315. #
  316. # which will install node.js and less in your virtualenv.
  317. USE_LESS = False
  318. COMPRESS_ENABLED = True
  319. COMPRESS_PRECOMPILERS = (
  320. ('text/less', 'lessc {infile} {outfile}'),
  321. )
  322. COMPRESS_OFFLINE_CONTEXT = {
  323. 'STATIC_URL': 'STATIC_URL',
  324. 'use_less': USE_LESS,
  325. }
  326. # We do this to work around an issue in compressor where the LESS files are
  327. # compiled but compression isn't enabled. When this happens, the relative URL
  328. # is wrong between the generated CSS file and other assets:
  329. # https://github.com/jezdez/django_compressor/issues/226
  330. COMPRESS_OUTPUT_DIR = 'oscar'
  331. # Logging
  332. # =======
  333. LOG_ROOT = location('logs')
  334. # Ensure log root exists
  335. if not os.path.exists(LOG_ROOT):
  336. os.mkdir(LOG_ROOT)
  337. # Sorl
  338. # ====
  339. THUMBNAIL_DEBUG = True
  340. THUMBNAIL_KEY_PREFIX = 'oscar-us-sandbox'
  341. # Django 1.6 has switched to JSON serializing for security reasons, but it does not
  342. # serialize Models. We should resolve this by extending the
  343. # django/core/serializers/json.Serializer to have the `dumps` function. Also
  344. # in tests/config.py
  345. SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
  346. # Try and import local settings which can be used to override any of the above.
  347. try:
  348. from settings_local import *
  349. except ImportError:
  350. pass