{ "info": { "author": "Robert Kajic", "author_email": "robert@kajic.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 :: 2", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "====================\ndjango-model-changes\n====================\n\ndjango-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\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": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/kajic/django-model-changes", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "django-model-changes", "package_url": "https://pypi.org/project/django-model-changes/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-model-changes/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/kajic/django-model-changes" }, "release_url": "https://pypi.org/project/django-model-changes/0.15/", "requires_dist": null, "requires_python": null, "summary": "django-model-changes allows you to track model instance changes.", "version": "0.15" }, "last_serial": 954918, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "3252bec7437fa50d49a33c442f5c3f35", "sha256": "61cbaf3fb41508942cc83c33a1de22211946e0f76c81bae1f41dd86af1c589e2" }, "downloads": -1, "filename": "django-model-changes-0.1.tar.gz", "has_sig": false, "md5_digest": "3252bec7437fa50d49a33c442f5c3f35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9262, "upload_time": "2013-10-12T20:18:57", "url": "https://files.pythonhosted.org/packages/85/fb/9625999d056a627fa81d1b977fea018bb5f668d37c54379811c4f764dfd8/django-model-changes-0.1.tar.gz" } ], "0.11": [ { "comment_text": "", "digests": { "md5": "20d447361481eeab2a663e70a0336e0c", "sha256": "c610c79226a7da8c28ea37a0807aec3c5ce6b43f6d343b136807abef4679edc3" }, "downloads": -1, "filename": "django-model-changes-0.11.tar.gz", "has_sig": false, "md5_digest": "20d447361481eeab2a663e70a0336e0c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11644, "upload_time": "2013-10-14T11:43:12", "url": "https://files.pythonhosted.org/packages/f4/5f/b986271d59a3469f5927c56db861320472c4e527e961e5f220c9bc6bed4b/django-model-changes-0.11.tar.gz" } ], "0.12": [ { "comment_text": "", "digests": { "md5": "797d853edc862a9a41d9a5de53dfd7ff", "sha256": "58e240b7719030c9828295fe3a20f1b016e0800534b56b6348aad7cfce895b78" }, "downloads": -1, "filename": "django-model-changes-0.12.tar.gz", "has_sig": false, "md5_digest": "797d853edc862a9a41d9a5de53dfd7ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11627, "upload_time": "2013-10-14T14:13:36", "url": "https://files.pythonhosted.org/packages/4a/17/20499c6d611306c71636cd4de84d347e1e17cb2770e13eb92ffd3823b7c0/django-model-changes-0.12.tar.gz" } ], "0.13": [ { "comment_text": "", "digests": { "md5": "683f26152fcf9c7c0796908fd9b1a098", "sha256": "e081e8a496fe04d25ecfc4a8ad5d395845439d023d69c7c90e1b505486ba463e" }, "downloads": -1, "filename": "django-model-changes-0.13.tar.gz", "has_sig": false, "md5_digest": "683f26152fcf9c7c0796908fd9b1a098", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11724, "upload_time": "2013-10-22T00:02:25", "url": "https://files.pythonhosted.org/packages/8b/49/21fcfbe5e6b588e4631f476085d4f788ad24d856b74b593372c775812091/django-model-changes-0.13.tar.gz" } ], "0.14": [ { "comment_text": "", "digests": { "md5": "59681e343589d196616a6c8bba34d7e7", "sha256": "2415fbd29725ac0afef8cbf12c356d84ef305b381b345bcef193d451f2b76ae8" }, "downloads": -1, "filename": "django-model-changes-0.14.tar.gz", "has_sig": false, "md5_digest": "59681e343589d196616a6c8bba34d7e7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11718, "upload_time": "2013-10-22T00:04:04", "url": "https://files.pythonhosted.org/packages/bd/83/d85fc108a98ab1bb10e88304d69262ed9c1a7aea27e8698768b879119ffa/django-model-changes-0.14.tar.gz" } ], "0.15": [ { "comment_text": "", "digests": { "md5": "e40e34bffc1208014d0d757cc066e98e", "sha256": "11ef53e85212ecd4005455a05cacdf4084c5d8ee86a357494424e9de67866eaa" }, "downloads": -1, "filename": "django-model-changes-0.15.tar.gz", "has_sig": false, "md5_digest": "e40e34bffc1208014d0d757cc066e98e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12084, "upload_time": "2013-12-26T10:44:54", "url": "https://files.pythonhosted.org/packages/2e/4f/62eef529d0004c3245c5705e1234853747d9c97c2fdf1ba7841e1e742532/django-model-changes-0.15.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e40e34bffc1208014d0d757cc066e98e", "sha256": "11ef53e85212ecd4005455a05cacdf4084c5d8ee86a357494424e9de67866eaa" }, "downloads": -1, "filename": "django-model-changes-0.15.tar.gz", "has_sig": false, "md5_digest": "e40e34bffc1208014d0d757cc066e98e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12084, "upload_time": "2013-12-26T10:44:54", "url": "https://files.pythonhosted.org/packages/2e/4f/62eef529d0004c3245c5705e1234853747d9c97c2fdf1ba7841e1e742532/django-model-changes-0.15.tar.gz" } ] }