I have an app(django-compressor) that I only want to run on my local machine and not the server. I know about the
try:
from local_settings import *
except ImportError:
pass
trick. But I was wondering if there was a better way to remove the app I only want run locally from the INSTALLED_APPS in the settings.py using Fabric.
I think the standard approach you mentioned is best; create a folder
settingswith three settings files;shared.py,production.pyanddevelopment.py. Settings that are common to all instances of your app are placed inshared.pyand this is imported fromproduction.pyanddevelopment.py. Then you can easily only addcompressorin your development settingsshared.py
development.py
You need to make sure then when developing, you run the development server with the
development.pysettings file:and similarly on your production server you do the same for
production.py(this is down to your implementation)This is a much better approach in the long term as you can also specify separate cache, database, search etc. settings too.
As an aside, instead of completely removing
compressorfrom your installed apps, you can simply enable and disable is using it’sCOMPRESS_ENABLEDsetting