Skip to main content

django-changes

A utility to store and access information about changes on objects in a Django project.

TravisButton

Installation

pip install django-changes

Add to your Python path or setup.py install and add 'changes' to your INSTALLED_APPS setting.

Usage

You can use by importing the helper:

from changes import changes
# ...
changes.add_change(someobj, who=request.user)

Or by using the object directly:

from changes.models import Change
# ...
Change.objects.add_change_for_object(someobj, why='Because')

To get a queryset of changes that were added for an objects:

changes.get_changes_for(someobj)

or:

Change.objects.get_changes_for_object(someobj)

To get a queryset of changes that were made by a user:

changes.get_changes_by(someuser)

or:

Change.objects.get_changes_by_user(someuser)

You can also do things like this:

Change.objects.all().by_user(someuser)
changes.get_changes_for(someobj).anonymous()

Included is a ‘Mixin’ for your models that you expect to be recording changes on a lot that will give you the reverse relation changes:

from changes.models import ChangesMixin
# ...
class SomeModel(ChangesMixin, models.Model)

This mixin will give you some helpful methods:

somemodelinstance.add_change(why='Time for change')
somemodelinstance.get_changes()

You can also add a change when saving:

somemodelinstance.save(changed=True, who=someuser, why='Changing')

The default behaviour is to not save a change:

somemodelinstance.save()

The mixin also omits a signal, change_added when a change is added for the object.

See the source code for more.

Need Help?

Email: rvause@gmail.com

Github: https://github.com/rvause/django-changes

Metadata

Release files for django-changes 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-changes 0.2.2
File Size Uploaded
django-changes-0.2.2.tar.gz 5.4 kB Details

Release files / django-changes-0.2.2.tar.gz

Download URL django-changes-0.2.2.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a755faaf6f671b88c533027fb0bd37e3dfab0a554ce7351983b98b977ab84257
BLAKE2b-256 checksum
How to use checksums
835c0616dcf627d7d5a5d02df8881c6b6532fe4daddf02ade34662ddff3278e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.2 This release

1 release file

0.2.1

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page