From cfa787384d7f3b79cea5bea71d798844fc7c29c2 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Date: Sat, 22 Mar 2014 22:32:27 +0530 Subject: [PATCH] fix(settings): fixes wrong cache config used for heroku * Installs `django-heroku-memcacheify` only on heroku to avoid installing `libmemcached-dev`[1] locally. [1] https://github.com/rdegges/django-heroku-memcacheify#install Fixes: https://github.com/pydanny/cookiecutter-django/issues/80 --- {{cookiecutter.repo_name}}/requirements.txt | 3 ++- .../{{cookiecutter.repo_name}}/config/settings.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.repo_name}}/requirements.txt b/{{cookiecutter.repo_name}}/requirements.txt index 6be74cd27..7e29bd87a 100644 --- a/{{cookiecutter.repo_name}}/requirements.txt +++ b/{{cookiecutter.repo_name}}/requirements.txt @@ -1,4 +1,5 @@ # This file is here because many Platforms as a Service look for # requirements.txt in the root directory of a project. -pylibmc==1.2.3 # +pylibmc==1.2.3 +django-heroku-memcacheify==0.5 -r requirements/production.txt diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/settings.py b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/settings.py index 8b014a232..15052a845 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/settings.py +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/config/settings.py @@ -388,7 +388,12 @@ class Production(Common): ########## CACHING # Only do this here because thanks to django-pylibmc-sasl and pylibmc memcacheify is painful to install on windows. - CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211") + try: + # See: https://github.com/rdegges/django-heroku-memcacheify + from memcacheify import memcacheify + CACHES = memcacheify() + except ImportError: + CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211") ########## END CACHING ########## Your production stuff: Below this line define 3rd party libary settings