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

settings.py 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. SEND_BROKEN_LINK_EMAILS = False
  17. ADMINS = (
  18. ('David Winterbottom', '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 override this default
  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': 'django.core.cache.backends.locmem.LocMemCache',
  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-gb'
  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. # needed by django-treebeard for admin (and potentially other libs)
  87. 'django.template.loaders.eggs.Loader',
  88. )
  89. TEMPLATE_CONTEXT_PROCESSORS = (
  90. "django.contrib.auth.context_processors.auth",
  91. "django.core.context_processors.request",
  92. "django.core.context_processors.debug",
  93. "django.core.context_processors.i18n",
  94. "django.core.context_processors.media",
  95. "django.core.context_processors.static",
  96. "django.contrib.messages.context_processors.messages",
  97. # Oscar specific
  98. 'oscar.apps.search.context_processors.search_form',
  99. 'oscar.apps.promotions.context_processors.promotions',
  100. 'oscar.apps.checkout.context_processors.checkout',
  101. 'oscar.core.context_processors.metadata',
  102. 'oscar.apps.customer.notifications.context_processors.notifications',
  103. )
  104. MIDDLEWARE_CLASSES = (
  105. 'django.middleware.common.CommonMiddleware',
  106. 'django.contrib.sessions.middleware.SessionMiddleware',
  107. 'django.middleware.csrf.CsrfViewMiddleware',
  108. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  109. 'django.contrib.messages.middleware.MessageMiddleware',
  110. 'django.middleware.transaction.TransactionMiddleware',
  111. 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
  112. 'debug_toolbar.middleware.DebugToolbarMiddleware',
  113. 'oscar.apps.basket.middleware.BasketMiddleware',
  114. )
  115. INTERNAL_IPS = ('127.0.0.1',)
  116. ROOT_URLCONF = 'urls'
  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': False,
  130. 'formatters': {
  131. 'verbose': {
  132. 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
  133. },
  134. 'simple': {
  135. 'format': '%(levelname)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. 'error_file': {
  160. 'level': 'INFO',
  161. 'class': 'oscar.core.logging.handlers.EnvFileHandler',
  162. 'filename': 'errors.log',
  163. 'formatter': 'verbose'
  164. },
  165. 'mail_admins': {
  166. 'level': 'ERROR',
  167. 'class': 'django.utils.log.AdminEmailHandler',
  168. 'filters': ['require_debug_false'],
  169. },
  170. },
  171. 'loggers': {
  172. 'django': {
  173. 'handlers': ['null'],
  174. 'propagate': True,
  175. 'level': 'INFO',
  176. },
  177. 'django.request': {
  178. 'handlers': ['mail_admins', 'error_file'],
  179. 'level': 'ERROR',
  180. 'propagate': False,
  181. },
  182. 'oscar.checkout': {
  183. 'handlers': ['console', 'checkout_file'],
  184. 'propagate': True,
  185. 'level': 'INFO',
  186. },
  187. 'datacash': {
  188. 'handlers': ['console'],
  189. 'propagate': True,
  190. 'level': 'INFO',
  191. },
  192. 'django.db.backends': {
  193. 'handlers': ['null'],
  194. 'propagate': False,
  195. 'level': 'DEBUG',
  196. },
  197. }
  198. }
  199. INSTALLED_APPS = [
  200. 'django.contrib.auth',
  201. 'django.contrib.contenttypes',
  202. 'django.contrib.sessions',
  203. 'django.contrib.sites',
  204. 'django.contrib.messages',
  205. 'django.contrib.admin',
  206. 'django.contrib.flatpages',
  207. 'django.contrib.staticfiles',
  208. 'django.contrib.gis',
  209. # Oscar dependencies
  210. 'compressor',
  211. 'south',
  212. # Oscar extensions
  213. 'stores',
  214. 'paypal',
  215. 'datacash',
  216. # External apps
  217. 'django_extensions',
  218. 'debug_toolbar',
  219. # For profile testing
  220. 'apps.user',
  221. 'apps.bigbang',
  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
  236. HAYSTACK_CONNECTIONS = {
  237. 'default': {
  238. 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
  239. 'URL': 'http://127.0.0.1:8983/solr',
  240. },
  241. }
  242. DEBUG_TOOLBAR_CONFIG = {
  243. 'INTERCEPT_REDIRECTS': False
  244. }
  245. AUTH_PROFILE_MODULE = 'user.Profile'
  246. # Oscar settings
  247. from oscar.defaults import *
  248. OSCAR_RECENTLY_VIEWED_PRODUCTS = 20
  249. OSCAR_ALLOW_ANON_CHECKOUT = True
  250. OSCAR_SHOP_NAME = 'Oscar'
  251. OSCAR_SHOP_TAGLINE = 'Demo'
  252. COMPRESS_ENABLED = False
  253. COMPRESS_PRECOMPILERS = (
  254. ('text/less', 'lessc {infile} {outfile}'),
  255. )
  256. THUMBNAIL_KEY_PREFIX = 'oscar-demo'
  257. LOG_ROOT = location('logs')
  258. # Ensure log root exists
  259. if not os.path.exists(LOG_ROOT):
  260. os.mkdir(LOG_ROOT)
  261. DISPLAY_VERSION = False
  262. USE_TZ = True
  263. # Must be within MEDIA_ROOT for sorl to work
  264. OSCAR_MISSING_IMAGE_URL = 'image_not_found.jpg'
  265. # Add stores node to navigation
  266. new_nav = OSCAR_DASHBOARD_NAVIGATION
  267. new_nav.append(
  268. {
  269. 'label': 'Stores',
  270. 'icon': 'icon-shopping-cart',
  271. 'children': [
  272. {
  273. 'label': 'Stores',
  274. 'url_name': 'stores-dashboard:store-list',
  275. },
  276. {
  277. 'label': 'Store groups',
  278. 'url_name': 'stores-dashboard:store-group-list',
  279. },
  280. ]
  281. })
  282. new_nav.append(
  283. {
  284. 'label': 'Datacash',
  285. 'icon': 'icon-globe',
  286. 'children': [
  287. {
  288. 'label': 'Transactions',
  289. 'url_name': 'datacash-transaction-list',
  290. },
  291. ]
  292. })
  293. OSCAR_DASHBOARD_NAVIGATION = new_nav
  294. GEOIP_PATH = os.path.join(os.path.dirname(__file__), 'geoip')
  295. try:
  296. from settings_local import *
  297. except ImportError:
  298. pass