Dirty tracking for Django models
django_dirty_bits is a library that tracks model's modification state. Ths lets you find out if you need to call save on a model or add it to post processing.
- Django 1.2+
- Registering your models
import dirty_bits class Author(models.Model): name = models.TextField() dirty_bits.register(Author)
- Registering all of your models
dirty_bits.register_all()
- Checking dirtiness
author = Author.objects.get(pj=3) author.is_dirty()
Running the tests requires you to either configure an environment with all the parts installed that are required in requirements/requirements.txt, or follow the following steps
- Create a sandbox
virtualenv {% virtual_env_name %} {% path to virtual_env_name %}/bin/activate
- Set the django settings to be test_settings
export DJANGO_SETTINGS_MODULE=test_settings
- Install requirements
pip install -r -U requirements/requirements.txt
- Running tests
python manage.py test