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

settings.py 12KB

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