Tag: django

Invalidate template fragment cache in Django 1.5

Django 1.5 does not have a utility method to delete template fragment cache, with arguments.

In order to achieve this, you must create a custom method:

Example usage:

… and delete the cache:

 

In django 1.6+ you can do this more easy:

Deploy with fabric on multiple servers

Ever needed to deploy with fabric on multiple machines?
Here’s a simple solution to aproach this issue.

In your fabfile.py , add these two methods:

Now, when deploying, for example:

you must use the following commands, in the correct order:

Fabric runs the “staging” or “deploy” commands first, setting the envrinoment variables, and then it runs the “deploy” command doing whatever you asked it to do.