{ "info": { "author": "Marty Alchin", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Django Historical Records\n=========================\n\nThis is from Marty Alchin's `Pro Django`_ book.\n\nSetup the virtualenv\n\n::\n\n $ virtualenv --no-site-packages ve\n $ source ve/bin/activate\n (ve)$ pip install -r requirements.pip\n \nOr install from PyPI\n\n::\n\n $ pip install django-historicalrecords\n\nImport the HistoricalRecords and attach it to your model like you would a custom Django manager.\n\n::\n\n from django.db import models\n from history.models import HistoricalRecords\n\n class TestModel(models.Model):\n \"\"\"A model for testing\"\"\"\n boolean = models.BooleanField(default=True)\n characters = models.CharField(blank=True, max_length=100)\n \n history = HistoricalRecords()\n\n class Admin:\n list_display = ('',)\n search_fields = ('',)\n\n def __unicode__(self):\n return u\"TestModel\"\n\nIf you run `manage.py syncdb` you'll see that it automatically creates a `Historical` version of whatever model you've attached it to.\n\n::\n\n (ve)$ ./manage.py syncdb\n Creating table auth_permission\n ... // snip // ...\n Creating table example_app_historicaltestmodel <- HistoricalTestModel!\n Creating table example_app_testmodel\n ... // snip // ...\n\nThe `HistoricalRecords` clone the model it is attached to and adds some extra fields that allow you to track the type of change made, the timestamp of when the change was saved and it has a descriptor that will return the original object at the time of the change.\n\n::\n\n (ve)$ ./manage.py shell\n >>> from example_app.models import TestModel\n >>> tm = TestModel.objects.create(boolean=True,characters=\"abc\")\n >>> tm.history.count()\n 1\n >>> most_recent = tm.history.most_recent()\n >>> most_recent.boolean\n True\n >>> most_recent.characters\n u'abc'\n >>> tm.boolean = False\n >>> tm.characters = \"def\"\n >>> tm.save()\n >>> tm.history.count()\n 2\n >>> tm.history.all()\n [, ]\n >>> from datetime import datetime\n >>> timestamp = datetime(2010,9,10,3,28,31,358548)\n >>> old_version = tm.history.as_of(timestamp)\n >>> old_version.boolean\n True\n >>> tm.boolean\n False\n >>> old_version.characters\n u'abc'\n >>> tm.characters\n 'def'\n >>> \n \n.. _Pro Django: http://prodjango.com", "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/smn/django-historicalrecords", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-historicalrecords", "package_url": "https://pypi.org/project/django-historicalrecords/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-historicalrecords/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/smn/django-historicalrecords" }, "release_url": "https://pypi.org/project/django-historicalrecords/1.1/", "requires_dist": null, "requires_python": null, "summary": "Marty Alchin's HistoricalRecords from the ProDjango book.", "version": "1.1" }, "last_serial": 991161, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "39cff502cf0e20b456c524262d106bca", "sha256": "e1991461e72ac48ffe5d7a59af2cadec1d8f2baf6bf322e0edd2a44aa3aa472f" }, "downloads": -1, "filename": "django_historicalrecords-1.0-py2.6.egg", "has_sig": false, "md5_digest": "39cff502cf0e20b456c524262d106bca", "packagetype": "bdist_egg", "python_version": "2.6", "requires_python": null, "size": 8489, "upload_time": "2011-01-21T18:59:24", "url": "https://files.pythonhosted.org/packages/f4/c2/a5deaf382e1266580529752837e65ded875d39024177f846c427f0e52f76/django_historicalrecords-1.0-py2.6.egg" }, { "comment_text": "", "digests": { "md5": "4146c63fcdc22d6a5da9455c36a5185a", "sha256": "03363ac945f898b7551b70e638dc68b91ba46a5d6fcda1f2138acdcf945e8643" }, "downloads": -1, "filename": "django-historicalrecords-1.0.tar.gz", "has_sig": false, "md5_digest": "4146c63fcdc22d6a5da9455c36a5185a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5676, "upload_time": "2011-01-21T18:59:35", "url": "https://files.pythonhosted.org/packages/54/fa/0d913a64073bb2cb2e92ae286bc9ffb21697bfe8428f567d3f1f488a4d72/django-historicalrecords-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "44372437f84db7538282574755f667f5", "sha256": "a8c38344a64d071c6eff6def7ee3656a19df40c17102c18c5c975024ddd2429a" }, "downloads": -1, "filename": "django-historicalrecords-1.1.tar.gz", "has_sig": false, "md5_digest": "44372437f84db7538282574755f667f5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5220, "upload_time": "2014-02-05T11:43:48", "url": "https://files.pythonhosted.org/packages/0f/7c/442d27c71d97489a2ab4c2c0dd6f24f484a128ec76f0771eae3bd7973f50/django-historicalrecords-1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "44372437f84db7538282574755f667f5", "sha256": "a8c38344a64d071c6eff6def7ee3656a19df40c17102c18c5c975024ddd2429a" }, "downloads": -1, "filename": "django-historicalrecords-1.1.tar.gz", "has_sig": false, "md5_digest": "44372437f84db7538282574755f667f5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5220, "upload_time": "2014-02-05T11:43:48", "url": "https://files.pythonhosted.org/packages/0f/7c/442d27c71d97489a2ab4c2c0dd6f24f484a128ec76f0771eae3bd7973f50/django-historicalrecords-1.1.tar.gz" } ] }