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

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