jjkester/django-auditlog — pull request #12 by vittoriozamboni (2014-10-03 13:29:14+00:00)
Title: Added include_fields and exclude_fields kwargs to register

Added include/exclude fields feature via `register` command as kwargs:
- if no `include_fields` or `exclude_fields` kwarg is specified, save all fields;
- if `include_fields` is specified, limit the set to the included fields;
- if `exclude_fields` is specified, remove them from the previous filtered set;

AuditLogModelRegistry` _registry` attribute is now a dictionary, with model as key and a dictionary with keys include_fields and include_fields as value (they are both lists):
```python
self._registry[model] = {
'include_fields': kwargs.get('include_fields', []),
'exclude_fields': kwargs.get('exclude_fields', []),
}
```

`register` method now can be used in this way:
```python
class LoggedModel(models.Model):
label = models.CharField(max_length=255)
attributes = JSONField(default={}, blank=True)
untracked_field = models.CharField(max_length=255, default='', blank=True)

def __unicode__(self):
return self.label

auditlog.register(LoggedModel, include_fields=['label', 'attributes'])
```

or

```python
auditlog.register(LoggedModel, exclude_fields=['untracked_field'])
```