You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings.py 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. """
  2. Settings for Oscar's demo site.
  3. Notes:
  4. * The demo site uses the stores extension which requires a spatial database.
  5. Only the postgis and spatialite backends are tested, but all backends
  6. supported by GeoDjango should work.
  7. """
  8. import os
  9. # Django settings for oscar project.
  10. PROJECT_DIR = os.path.dirname(__file__)
  11. location = lambda x: os.path.join(
  12. os.path.dirname(os.path.realpath(__file__)), x)
  13. DEBUG = True
  14. TEMPLATE_DEBUG = True
  15. SQL_DEBUG = True
  16. ADMINS = (
  17. )
  18. EMAIL_SUBJECT_PREFIX = '[Oscar demo] '
  19. EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
  20. ALLOWED_HOSTS = ['demo.oscarcommerce.com',
  21. 'demo.oscar.tangentlabs.co.uk']
  22. MANAGERS = ADMINS
  23. # Use settings_local to override this default
  24. DATABASES = {
  25. 'default': {
  26. 'ENGINE': 'django.contrib.gis.db.backends.postgis',
  27. 'NAME': 'oscar_demo',
  28. 'USER': 'm',
  29. },
  30. }
  31. CACHES = {
  32. 'default': {
  33. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  34. }
  35. }
  36. # Local time zone for this installation. Choices can be found here:
  37. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  38. # although not all choices may be available on all operating systems.
  39. # On Unix systems, a value of None will cause Django to use the same
  40. # timezone as the operating system.
  41. # If running in a Windows environment this must be set to the same as your
  42. # system time zone.
  43. TIME_ZONE = 'Europe/London'
  44. # Language code for this installation. All choices can be found here:
  45. # http://www.i18nguy.com/unicode/language-identifiers.html
  46. LANGUAGE_CODE = 'en-gb'
  47. LANGUAGES = (
  48. ('en-gb', 'English'),
  49. )
  50. SITE_ID = 1
  51. # If you set this to False, Django will make some optimizations so as not
  52. # to load the internationalization machinery.
  53. USE_I18N = True
  54. # Absolute path to the directory that holds media.
  55. # Example: "/home/media/media.lawrence.com/"
  56. MEDIA_ROOT = location("public/media")
  57. # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  58. # trailing slash if there is a path component (optional in other cases).
  59. # Examples: "http://media.lawrence.com", "http://example.com/media/"
  60. MEDIA_URL = '/media/'
  61. # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
  62. # trailing slash.
  63. # Examples: "http://foo.com/media/", "/media/".
  64. #ADMIN_MEDIA_PREFIX = '/media/admin/'
  65. STATIC_URL = '/static/'
  66. STATICFILES_DIRS = (
  67. location('static'),
  68. )
  69. STATIC_ROOT = location('public/static')
  70. STATICFILES_FINDERS = (
  71. 'django.contrib.staticfiles.finders.FileSystemFinder',
  72. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  73. 'compressor.finders.CompressorFinder',
  74. )
  75. # Make this unique, and don't share it with anybody.
  76. SECRET_KEY = '$)a7n&o80u!6y5t-+jrd3)3!%vh&shg$wqpjpxc!ar&p#!)n1a'
  77. # List of callables that know how to import templates from various sources.
  78. TEMPLATE_LOADERS = (
  79. 'django.template.loaders.filesystem.Loader',
  80. 'django.template.loaders.app_directories.Loader',
  81. # needed by django-treebeard for admin (and potentially other libs)
  82. 'django.template.loaders.eggs.Loader',
  83. )
  84. TEMPLATE_CONTEXT_PROCESSORS = (
  85. "django.contrib.auth.context_processors.auth",
  86. "django.core.context_processors.request",
  87. "django.core.context_processors.debug",
  88. "django.core.context_processors.i18n",
  89. "django.core.context_processors.media",
  90. "django.core.context_processors.static",
  91. "django.contrib.messages.context_processors.messages",
  92. # Oscar specific
  93. 'oscar.apps.search.context_processors.search_form',
  94. 'oscar.apps.promotions.context_processors.promotions',
  95. 'oscar.apps.checkout.context_processors.checkout',
  96. 'oscar.core.context_processors.metadata',
  97. 'oscar.apps.customer.notifications.context_processors.notifications',
  98. )
  99. MIDDLEWARE_CLASSES = (
  100. 'django.middleware.common.CommonMiddleware',
  101. 'django.contrib.sessions.middleware.SessionMiddleware',
  102. 'django.middleware.csrf.CsrfViewMiddleware',
  103. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  104. 'django.contrib.messages.middleware.MessageMiddleware',
  105. 'django.middleware.transaction.TransactionMiddleware',
  106. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  107. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  108. 'oscar.apps.basket.middleware.BasketMiddleware',
  109. )
  110. DEBUG_TOOLBAR_PATCH_SETTINGS = False
  111. INTERNAL_IPS = ('127.0.0.1',)
  112. DEBUG_TOOLBAR_CONFIG = {
  113. 'INTERCEPT_REDIRECTS': False
  114. }
  115. ROOT_URLCONF = 'urls'
  116. from oscar import OSCAR_MAIN_TEMPLATE_DIR
  117. TEMPLATE_DIRS = (
  118. location('templates'),
  119. OSCAR_MAIN_TEMPLATE_DIR,
  120. )
  121. # A sample logging configuration. The only tangible logging
  122. # performed by this configuration is to send an email to
  123. # the site admins on every HTTP 500 error.
  124. # See http://docs.djangoproject.com/en/dev/topics/logging for
  125. # more details on how to customize your logging configuration.
  126. LOGGING = {
  127. 'version': 1,
  128. 'disable_existing_loggers': False,
  129. 'formatters': {
  130. 'verbose': {
  131. 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
  132. },
  133. 'simple': {
  134. 'format': '%(levelname)s %(message)s'
  135. },
  136. },
  137. 'filters': {
  138. 'require_debug_false': {
  139. '()': 'django.utils.log.RequireDebugFalse'
  140. }
  141. },
  142. 'handlers': {
  143. 'null': {
  144. 'level': 'DEBUG',
  145. 'class': 'django.utils.log.NullHandler',
  146. },
  147. 'console': {
  148. 'level': 'DEBUG',
  149. 'class': 'logging.StreamHandler',
  150. 'formatter': 'verbose'
  151. },
  152. 'checkout_file': {
  153. 'level': 'INFO',
  154. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  155. 'filename': 'checkout.log',
  156. 'formatter': 'verbose'
  157. },
  158. 'error_file': {
  159. 'level': 'INFO',
  160. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  161. 'filename': 'errors.log',
  162. 'formatter': 'verbose'
  163. },
  164. 'mail_admins': {
  165. 'level': 'ERROR',
  166. 'class': 'django.utils.log.AdminEmailHandler',
  167. 'filters': ['require_debug_false'],
  168. },
  169. },
  170. 'loggers': {
  171. 'django': {
  172. 'handlers': ['null'],
  173. 'propagate': True,
  174. 'level': 'INFO',
  175. },
  176. 'django.request': {
  177. 'handlers': ['mail_admins', 'error_file'],
  178. 'level': 'ERROR',
  179. 'propagate': False,
  180. },
  181. 'oscar.checkout': {
  182. 'handlers': ['console', 'checkout_file'],
  183. 'propagate': True,
  184. 'level': 'INFO',
  185. },
  186. 'datacash': {
  187. 'handlers': ['console'],
  188. 'propagate': True,
  189. 'level': 'INFO',
  190. },
  191. 'django.db.backends': {
  192. 'handlers': ['null'],
  193. 'propagate': False,
  194. 'level': 'DEBUG',
  195. },
  196. }
  197. }
  198. INSTALLED_APPS = [
  199. 'django.contrib.auth',
  200. 'django.contrib.contenttypes',
  201. 'django.contrib.sessions',
  202. 'django.contrib.sites',
  203. 'django.contrib.messages',
  204. 'django.contrib.admin',
  205. 'django.contrib.flatpages',
  206. 'django.contrib.staticfiles',
  207. 'django.contrib.gis',
  208. # Oscar dependencies
  209. 'compressor',
  210. 'south',
  211. # Oscar extensions
  212. 'stores',
  213. 'paypal',
  214. 'datacash',
  215. # External apps
  216. 'django_extensions',
  217. 'debug_toolbar',
  218. # For profile testing
  219. 'apps.user',
  220. # Sentry (for live demo site)
  221. 'raven.contrib.django.raven_compat'
  222. ]
  223. # Include core apps with a few overrides:
  224. # - a shipping override app to provide some shipping methods
  225. # - an order app to provide order processing logic
  226. from oscar import get_core_apps
  227. INSTALLED_APPS = INSTALLED_APPS + get_core_apps(
  228. ['apps.shipping', 'apps.order'])
  229. AUTHENTICATION_BACKENDS = (
  230. 'oscar.apps.customer.auth_backends.Emailbackend',
  231. 'django.contrib.auth.backends.ModelBackend',
  232. )
  233. LOGIN_REDIRECT_URL = '/'
  234. APPEND_SLASH = True
  235. # Haystack settings - we use a local Solr instance running on the default port
  236. HAYSTACK_CONNECTIONS = {
  237. 'default': {
  238. 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
  239. 'URL': 'http://127.0.0.1:8983/solr',
  240. },
  241. }
  242. AUTH_PROFILE_MODULE = 'user.Profile'
  243. # Oscar settings
  244. from oscar.defaults import *
  245. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  246. OSCAR_ALLOW_ANON_CHECKOUT = True
  247. OSCAR_SHOP_NAME = 'Oscar'
  248. OSCAR_SHOP_TAGLINE = 'Demo'
  249. COMPRESS_ENABLED = False
  250. COMPRESS_PRECOMPILERS = (
  251. ('text/less', 'lessc {infile} {outfile}'),
  252. )
  253. THUMBNAIL_KEY_PREFIX = 'oscar-demo'
  254. LOG_ROOT = location('logs')
  255. # Ensure log root exists
  256. if not os.path.exists(LOG_ROOT):
  257. os.mkdir(LOG_ROOT)
  258. DISPLAY_VERSION = False
  259. USE_TZ = True
  260. # Must be within MEDIA_ROOT for sorl to work
  261. OSCAR_MISSING_IMAGE_URL = 'image_not_found.jpg'
  262. GOOGLE_ANALYTICS_ID = 'UA-45363517-4'
  263. # Add stores node to navigation
  264. new_nav = OSCAR_DASHBOARD_NAVIGATION
  265. new_nav.append(
  266. {
  267. 'label': 'Stores',
  268. 'icon': 'icon-shopping-cart',
  269. 'children': [
  270. {
  271. 'label': 'Stores',
  272. 'url_name': 'stores-dashboard:store-list',
  273. },
  274. {
  275. 'label': 'Store groups',
  276. 'url_name': 'stores-dashboard:store-group-list',
  277. },
  278. ]
  279. })
  280. new_nav.append(
  281. {
  282. 'label': 'Datacash',
  283. 'icon': 'icon-globe',
  284. 'children': [
  285. {
  286. 'label': 'Transactions',
  287. 'url_name': 'datacash-transaction-list',
  288. },
  289. ]
  290. })
  291. OSCAR_DASHBOARD_NAVIGATION = new_nav
  292. GEOIP_PATH = os.path.join(os.path.dirname(__file__), 'geoip')
  293. #default currency for django-oscar-datacash
  294. DATACASH_CURRENCY = "GBP"
  295. try:
  296. from settings_local import *
  297. except ImportError:
  298. pass