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.3KB

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