baseapp-django-pghistory


Namebaseapp-django-pghistory JSON
Version 2.8.2 PyPI version JSON
download
home_pagehttps://github.com/silverlogic/django-pghistory
SummaryHistory tracking for Django and Postgres (updated for Baseapp)
upload_time2023-10-09 20:40:14
maintainer
docs_urlNone
authorWes Kendall
requires_python>=3.7.0,<4
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            django-pghistory
################

This is a fork of https://github.com/Opus10/django-pghistory.

``django-pghistory`` tracks changes to your Django models
using `Postgres triggers <https://www.postgresql.org/docs/current/sql-createtrigger.html>`__.
It offers several advantages over other apps:

* No base models or managers to inherit, no signal handlers, and no custom save methods.
  All changes are reliably tracked, including bulk methods, with miniscule code.
* Snapshot all changes to your models, create conditional event trackers, or only
  track the fields you care about.
* Changes are stored in structured event tables that mirror your models. No JSON, and you
  can easily query events in your application.
* Changes can be grouped together with additional context attached, such as the logged-in
  user. The middleware can do this automatically.

``django-pghistory`` has a number of ways in which you can configure tracking models
for your application's needs and for performance and scale. An admin integration
is included out of the box too.

.. _quick_start:

Quick Start
===========

Decorate your model with ``pghistory.track``. For example:

.. code-block:: python

    import pghistory

    @pghistory.track(pghistory.Snapshot())
    class TrackedModel(models.Model):
        int_field = models.IntegerField()
        text_field = models.TextField()


Above we've registered a ``pghistory.Snapshot`` event tracker to ``TrackedModel``.
This event tracker stores every change in a dynamically-created
model that mirrors fields in ``TrackedModel``.

Run ``python manage.py makemigrations`` followed by ``migrate`` and
*voila*, every change to ``TrackedModel`` is now stored. This includes bulk
methods and even changes that happen in raw SQL. For example:

.. code-block:: python

    from myapp.models import TrackedModel

    # Even though we didn't declare TrackedModelEvent, django-pghistory
    # creates it for us in our app
    from myapp.models import TrackedModelEvent

    m = TrackedModel.objects.create(int_field=1, text_field="hello")
    m.int_field = 2
    m.save()

    print(TrackedModelEvent.objects.values("pgh_obj", "int_field"))

    > [{'pgh_obj': 1, 'int_field': 1}, {'pgh_obj': 1, 'int_field': 2}]

Above we printed the ``pgh_obj`` field, which is a special foreign key to the tracked
object. There are a few other special ``pgh_`` fields that we'll discuss later.

``django-pghistory`` can track a subset of fields and conditionally store events
based on specific field transitions. Users can also store free-form context
from the application that's referenced by the event model, all with no additional
database queries. See the next steps below on how to dive deeper and configure it
for your use case.

Compatibility
=============

``django-pghistory`` is compatible with Python 3.7 - 3.11, Django 3.2 - 4.2, Psycopg 2 - 3 and Postgres 12 - 15.

Documentation
=============

`View the django-pghistory docs here
<https://django-pghistory.readthedocs.io/>`_ to learn more about:

* The basics and terminology.
* Tracking historical events on models.
* Attaching dynamic application context to events.
* Configuring event models.
* Aggregating events across event models.
* The Django admin integration.
* Reverting models to previous versions.
* A guide on performance and scale.

There's also additional help, FAQ, and troubleshooting guides.

Installation
============

Install django-pghistory with::

    pip3 install django-pghistory

After this, add ``pghistory`` and ``pgtrigger`` to the ``INSTALLED_APPS``
setting of your Django project.

Contributing Guide
==================

For information on setting up django-pghistory for development and
contributing changes, view `CONTRIBUTING.rst <CONTRIBUTING.rst>`_.

Primary Authors
===============

- @wesleykendall (Wes Kendall, wesleykendall@protonmail.com)

Other Contributors
==================

- @shivananda-sahu
- @asucrews
- @Azurency
- @dracos
- @adamchainz
- @eeriksp

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/silverlogic/django-pghistory",
    "name": "baseapp-django-pghistory",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.0,<4",
    "maintainer_email": "",
    "keywords": "",
    "author": "Wes Kendall",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/b8/5e/bf2b6d9ec506eac0ed25b72ab68e090fc283660563c60d8f8f599e1e7aae/baseapp_django_pghistory-2.8.2.tar.gz",
    "platform": null,
    "description": "django-pghistory\n################\n\nThis is a fork of https://github.com/Opus10/django-pghistory.\n\n``django-pghistory`` tracks changes to your Django models\nusing `Postgres triggers <https://www.postgresql.org/docs/current/sql-createtrigger.html>`__.\nIt offers several advantages over other apps:\n\n* No base models or managers to inherit, no signal handlers, and no custom save methods.\n  All changes are reliably tracked, including bulk methods, with miniscule code.\n* Snapshot all changes to your models, create conditional event trackers, or only\n  track the fields you care about.\n* Changes are stored in structured event tables that mirror your models. No JSON, and you\n  can easily query events in your application.\n* Changes can be grouped together with additional context attached, such as the logged-in\n  user. The middleware can do this automatically.\n\n``django-pghistory`` has a number of ways in which you can configure tracking models\nfor your application's needs and for performance and scale. An admin integration\nis included out of the box too.\n\n.. _quick_start:\n\nQuick Start\n===========\n\nDecorate your model with ``pghistory.track``. For example:\n\n.. code-block:: python\n\n    import pghistory\n\n    @pghistory.track(pghistory.Snapshot())\n    class TrackedModel(models.Model):\n        int_field = models.IntegerField()\n        text_field = models.TextField()\n\n\nAbove we've registered a ``pghistory.Snapshot`` event tracker to ``TrackedModel``.\nThis event tracker stores every change in a dynamically-created\nmodel that mirrors fields in ``TrackedModel``.\n\nRun ``python manage.py makemigrations`` followed by ``migrate`` and\n*voila*, every change to ``TrackedModel`` is now stored. This includes bulk\nmethods and even changes that happen in raw SQL. For example:\n\n.. code-block:: python\n\n    from myapp.models import TrackedModel\n\n    # Even though we didn't declare TrackedModelEvent, django-pghistory\n    # creates it for us in our app\n    from myapp.models import TrackedModelEvent\n\n    m = TrackedModel.objects.create(int_field=1, text_field=\"hello\")\n    m.int_field = 2\n    m.save()\n\n    print(TrackedModelEvent.objects.values(\"pgh_obj\", \"int_field\"))\n\n    > [{'pgh_obj': 1, 'int_field': 1}, {'pgh_obj': 1, 'int_field': 2}]\n\nAbove we printed the ``pgh_obj`` field, which is a special foreign key to the tracked\nobject. There are a few other special ``pgh_`` fields that we'll discuss later.\n\n``django-pghistory`` can track a subset of fields and conditionally store events\nbased on specific field transitions. Users can also store free-form context\nfrom the application that's referenced by the event model, all with no additional\ndatabase queries. See the next steps below on how to dive deeper and configure it\nfor your use case.\n\nCompatibility\n=============\n\n``django-pghistory`` is compatible with Python 3.7 - 3.11, Django 3.2 - 4.2, Psycopg 2 - 3 and Postgres 12 - 15.\n\nDocumentation\n=============\n\n`View the django-pghistory docs here\n<https://django-pghistory.readthedocs.io/>`_ to learn more about:\n\n* The basics and terminology.\n* Tracking historical events on models.\n* Attaching dynamic application context to events.\n* Configuring event models.\n* Aggregating events across event models.\n* The Django admin integration.\n* Reverting models to previous versions.\n* A guide on performance and scale.\n\nThere's also additional help, FAQ, and troubleshooting guides.\n\nInstallation\n============\n\nInstall django-pghistory with::\n\n    pip3 install django-pghistory\n\nAfter this, add ``pghistory`` and ``pgtrigger`` to the ``INSTALLED_APPS``\nsetting of your Django project.\n\nContributing Guide\n==================\n\nFor information on setting up django-pghistory for development and\ncontributing changes, view `CONTRIBUTING.rst <CONTRIBUTING.rst>`_.\n\nPrimary Authors\n===============\n\n- @wesleykendall (Wes Kendall, wesleykendall@protonmail.com)\n\nOther Contributors\n==================\n\n- @shivananda-sahu\n- @asucrews\n- @Azurency\n- @dracos\n- @adamchainz\n- @eeriksp\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "History tracking for Django and Postgres (updated for Baseapp)",
    "version": "2.8.2",
    "project_urls": {
        "Documentation": "https://django-pghistory.readthedocs.io",
        "Homepage": "https://github.com/silverlogic/django-pghistory",
        "Repository": "https://github.com/silverlogic/django-pghistory"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d160e86f12c321123246465bf2ee289174ca852b54b808c178cb21bd6ffe9f7f",
                "md5": "23747ec7774e9aa884476d2f06d7cf58",
                "sha256": "41d3b95c6fc6ce4960ea0581129ed9d56344a84d1168ed46a697d60f909fc0c1"
            },
            "downloads": -1,
            "filename": "baseapp_django_pghistory-2.8.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "23747ec7774e9aa884476d2f06d7cf58",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.0,<4",
            "size": 39687,
            "upload_time": "2023-10-09T20:40:12",
            "upload_time_iso_8601": "2023-10-09T20:40:12.678907Z",
            "url": "https://files.pythonhosted.org/packages/d1/60/e86f12c321123246465bf2ee289174ca852b54b808c178cb21bd6ffe9f7f/baseapp_django_pghistory-2.8.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b85ebf2b6d9ec506eac0ed25b72ab68e090fc283660563c60d8f8f599e1e7aae",
                "md5": "d94170d39f064bacfac5f88d4a9e9e32",
                "sha256": "609aa48c14eaefd8d847ee4690e293bcd5b910efac919da7f65c0c068eed687e"
            },
            "downloads": -1,
            "filename": "baseapp_django_pghistory-2.8.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d94170d39f064bacfac5f88d4a9e9e32",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.0,<4",
            "size": 32907,
            "upload_time": "2023-10-09T20:40:14",
            "upload_time_iso_8601": "2023-10-09T20:40:14.318522Z",
            "url": "https://files.pythonhosted.org/packages/b8/5e/bf2b6d9ec506eac0ed25b72ab68e090fc283660563c60d8f8f599e1e7aae/baseapp_django_pghistory-2.8.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-09 20:40:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "silverlogic",
    "github_project": "django-pghistory",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "tox": true,
    "lcname": "baseapp-django-pghistory"
}
        
Elapsed time: 0.12835s