Metadata-Version: 1.1
Name: django-fieldsignals
Version: 0.1.1
Summary: Django fieldsignals simply makes it easy to tell when the fields on your model have changed.
Home-page: https://github.com/craigds/django-fieldsignals
Author: Craig de Stigter
Author-email: craig.ds@gmail.com
License: UNKNOWN
Description: ============
        Introduction
        ============
        .. highlightlang:: python
        
        ``django-fieldsignals`` simply makes it easy to tell when the fields on your model have changed.
        
        Often model updates are quite expensive. Sometimes the expensive operations
        are sometimes very rare. This makes it tempting to put the update logic in a view,
        rather than in a save() method or in a signal receiver::
        
            # A bad example. Don't do this!
            def edit_poll(request, poll_id):
            
                # ...
                
                if form.cleaned_data['poll_name'] != poll.name:
                    poll.update_slug(form.cleaned_data['poll_name'])
                poll.save()
        
        
        That's a bad idea, because your model consistency is now dependent on your view.
        
        Instead, use ``fieldsignals``::
            
            from fieldsignals import pre_save_changed
            
            def update_poll_slug(sender, instance, **kwargs):
                instance.slug = slugify(instance.name)
            
            pre_save_changed.connect(update_poll_slug, sender=Poll, fields=['name'])
        
        
        In case you want to know what changed, ``fieldsignals`` even tells you the old and
        new values of your fields::
        
            from fieldsignals import pre_save_changed
        
            def print_all_field_changes(sender, instance, changed_fields=None, **kwargs):
                for field, (old, new) in changed_fields.items():
                    print "%s changed from %s to %s" % (field.name, old, new)
            
            pre_save_changed.connect(print_all_field_changes, sender=Poll)
        
        Installation
        -----------
        
        1. This library is on PyPI so you can install it with::
        
            pip install django-fieldsignals
        
        or from github::
        
            pip install git+https://github.com/craigds/django-fieldsignals.git#egg=django-fieldsignals
        
        2. Add "polls" to your INSTALLED_APPS setting like this::
        
            INSTALLED_APPS = (
                ...
                'fieldsignals',
            )
        
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
