cobrateam/roan — Issue #5: Add support for purge urls on saving and deleting model instances 
Author: fsouza
Created: 2011-11-20 03:22:22+00:00
State: open
Labels: 0.2

roan shall support purging URLs on save and delete model instances too.

Imagine you're using [django.contrib.flatpages](https://docs.djangoproject.com/en/1.3/ref/contrib/flatpages/) app and have the ``/about/contact/`` page, it would nice to be able to purge only that page when you save or delete the instance ``/about/contact/``, not any instance. Something like this:

```python
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import Site
from roan import purge

flatpage = FlatPage.objects.get_or_create(url=u'/about/contact/', title=u'Contact')
flatpage.sites = (Site.objects.get_or_create(domain=u'example.com', name=u'example.com'),)

purge(flatpage.url).on_save(flatpage)
purge(flatpage.url).on_delete(flatpage)
```

The alternative today is to purge all flatpages URL on saving or deleting one of them:

```python
from django.contrib.flatpages.models import FlatPage
from roan import purge

flatpages = FlatPage.objects.all()
for f in flatpages:
purge(f.url).on_save(FlatPage)
```

And that's not nice :)