{ "info": { "author": "Ian Price", "author_email": "iprice@thermaline.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "========================\ndjango-model-changes-py3\n========================\n\nPYTHON 3 FORK OF `django-model-changes `_.\n\n*django-model-changes* allows you to track the state and changes of a model instance:\n\nQuick start\n-----------\n\n1. Install django-model-changes::\n\n pip install django-model-changes-py3\n\n2. Add \"django_model_changes\" to your INSTALLED_APPS setting like this::\n\n INSTALLED_APPS = (\n ...\n 'django_model_changes',\n )\n\n3. Add the `ChangesMixin` to your model::\n\n >>> from django.db import models\n >>> from django_model_changes import ChangesMixin\n\n >>> class User(ChangesMixin, models.Model):\n >>> name = models.CharField(max_length=100)\n\n4. Get instance changes::\n\n >>> user = User()\n >>> user.name = 'Foo Bar'\n >>> user.save()\n\n >>> user.name 'I got a new name'\n\n >>> # Get current state\n >>> user.current_state()\n {'id': 1, 'name': 'I got a new name'}\n\n >>> # Get previous state (state after previous save/create/delete)\n >>> user.previous_state()\n {'id': 1, 'name': 'Foo Bar'}\n\n >>> # Get old state (state before previous save/create/delete)\n >>> user.old_state()\n {'id': None, 'name': ''}\n\n >>> # Get changes from the previous state to the current state\n >>> user.changes()\n {'name': ('Foo Bar', 'I got a new name')}\n\n >>> # Get changes from the old state to the current state\n >>> user.old_changes()\n {'id': (None, 1), 'name': ('', 'Foo Bar')}\n\n >>> # Check if the instance was persisted (saved)\n >>> user.was_persisted()\n False\n\n >>> # Check if the instance is persisted\n >>> user.is_persisted()\n True\n\n5. Listen for changes::\n \n >>> from django_model_changes import post_change\n \n >>> def my_callback(sender, instance, **kwargs):\n >>> # Do something with previous and current state\n >>> instance.old_state()\n >>> instance.current_state()\n\n >>> # There is also a convenience method to get\n >>> # an instance from the previous state\n >>> instance.old_instance()\n\n >>> post_change.connect(my_callback, User)\n\nOverview\n--------\n\ndjango-model-changes allows you to retrieve the following states from an\ninstance:\n\n1. current_state()\n The current state of the instance.\n2. previous_state()\n The state of the instance **after** it was created, saved or deleted the\n last time.\n3. old_state()\n The previous previous_state(), i.e. the state of the instance **before**\n it was created, saved or deleted the last time.\n\nIt also provides convenience methods to get changes between states:\n\n1. changes()\n Changes from previous_state to current_state.\n2. previous_changes()\n Changes from old_state to previous_state.\n3. old_changes()\n Changes from old_state to current_state.\n\nAnd the following methods to determine if an instance was/is persisted in\nthe database:\n\n1. was_persisted()\n Was the instance persisted in its old state.\n2. is_persisted()\n Is the instance is_persisted in its current state.\n\nThis schematic tries to illustrate how these methods relate to each other::\n\n\n after create/save/delete after save/delete now\n | | |\n .-----------------------------------.----------------------------------.\n |\\ |\\ |\\\n | \\ | \\ | \\\n | old_state() | previous_state() | current_state()\n | | |\n |-----------------------------------|----------------------------------|\n | previous_changes() (prev - old) | changes() (cur - prev) |\n |-----------------------------------|----------------------------------|\n | old_changes() (cur - old) |\n .----------------------------------------------------------------------.\n \\ \\\n \\ \\\n was_persisted() is_persisted()\n\n\nDocumentation\n-------------\n\nRefer to the doc strings in `changes.py`_, or build the documentation::\n\n >>> pip install Sphinx\n >>> cd docs\n >>> make html\n Open build/html/index.html\n\n.. _changes.py: django_model_changes/changes.py", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/iansprice/django-model-changes-py3", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "django-model-changes-py3", "package_url": "https://pypi.org/project/django-model-changes-py3/", "platform": "", "project_url": "https://pypi.org/project/django-model-changes-py3/", "project_urls": { "Homepage": "http://github.com/iansprice/django-model-changes-py3" }, "release_url": "https://pypi.org/project/django-model-changes-py3/0.15.1/", "requires_dist": null, "requires_python": "", "summary": "django-model-changes allows you to track model instance changes.", "version": "0.15.1" }, "last_serial": 3848203, "releases": { "0.14.1": [ { "comment_text": "", "digests": { "md5": "55266934697bf9e64704ccd29d18fb81", "sha256": "08a28b73022b6ea31ab4b4d9df635e2fe7f536de52c7e821f9bc7aeee86248c6" }, "downloads": -1, "filename": "django-model-changes-py3-0.14.1.tar.gz", "has_sig": false, "md5_digest": "55266934697bf9e64704ccd29d18fb81", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13409, "upload_time": "2016-11-23T22:50:13", "url": "https://files.pythonhosted.org/packages/dd/44/81cc3a0404ab1d5dab8ed37a7135e4e9abd2b2bf391cb2033733ae45e4b7/django-model-changes-py3-0.14.1.tar.gz" } ], "0.15.1": [ { "comment_text": "", "digests": { "md5": "54a94b12d0409aed025a8041a3434b99", "sha256": "f49f30ed47d3e1cc8be3f07f69a8c6aae4c020325255cb2e2183aaf5000f469f" }, "downloads": -1, "filename": "django-model-changes-py3-0.15.1.tar.gz", "has_sig": false, "md5_digest": "54a94b12d0409aed025a8041a3434b99", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12091, "upload_time": "2018-05-09T17:48:27", "url": "https://files.pythonhosted.org/packages/0e/28/afaf74c2e60e465b96f09476df2f9fc52ee0b5ed6ebe3438d522ea926f7a/django-model-changes-py3-0.15.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "54a94b12d0409aed025a8041a3434b99", "sha256": "f49f30ed47d3e1cc8be3f07f69a8c6aae4c020325255cb2e2183aaf5000f469f" }, "downloads": -1, "filename": "django-model-changes-py3-0.15.1.tar.gz", "has_sig": false, "md5_digest": "54a94b12d0409aed025a8041a3434b99", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12091, "upload_time": "2018-05-09T17:48:27", "url": "https://files.pythonhosted.org/packages/0e/28/afaf74c2e60e465b96f09476df2f9fc52ee0b5ed6ebe3438d522ea926f7a/django-model-changes-py3-0.15.1.tar.gz" } ] }