This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Author

Requirements

  • Tested against Python 2.7 and 3.4
  • django-record supports django 1.7 or later.
  • Requires pandas 0.17.0 or later.
  • Requires faker for tests.

Installation

pip install django-record

Rationale

Often there are situations where you want to record your properties of your models and where you want to track their changes. Although that recording process can be implemented by handcrafted, ad-hoc signals or overriding save() methods of your models, it’s not a generic way, and it’ll eventually mess up your code base.

django-record automatically creates an snapshot-like extra record when an audited Django model instance has been changed either directly or indirectly, without messing up your code base.

RecordModel will detect any changes in recording_fields of recording_model at it’s post_save time or auditing_relatives’s post_save time and create an new record for it.

You can access records via record manager records in your recorded model instance. You can also access recorded model’s instance via recording, which is in effect just ordinary ForeignKey, from your records.

More conveniently, just mix RecordedModelMixin into your model and provide recording_fields and auditing_relatives.

Usage

from django.db import models
from django_record.mixins import RecordedModelMixin


class MyTopic(models.Model):
    title = models.CharField(max_length=100)


class MyArticle(RecordedModelMixin, models.Model):
    topic = models.ForeignKey(MyTopic)
    text = models.TextField()

    @property
    def my_local_property(self):
        return self.text

    @property
    def my_nonlocal_property(self):
        return self.topic.title + self.text

    # We will monitor `topic` relative to watch if he changes!
    auditing_relatives = ['topic']

    recording_fields = [
        # Record changes of the model instance's `text` field
        'text',
        # Yayy! we can record changes on properties too!
        ('my_local_property', models.TextField()),
        # Even indirect effects from relatives are recordable!
        ('my_nonlocal_property', models.TextField())
    ]


 # To get the model instance's all records
 >>> my_article.records.all()

 # To get queryset of the model instance's records created in specific
 # time threshold
 >>> my_article.records.created_in_years(2)
 >>> my_article.records.created_in_days(3)
 >>> my_article.records.created_in_minutes(5)

 # To resample records of today by hour
 >>> my_article.records.created_in_days().resample('T')

 # To get record contents
 >>> my_article.records.first().text
 >>> my_article.records.first().my_local_property
 >>> my_article.records.first().my_nonlocal_property

Note

  • Recursive auditing is currently not supported. Indirect effect only those from direct relatives will be detected and recorded.
  • Only primitive types are supported for properties. You must offer appropriate django field for them.
  • RecordModel is also a subclass of TimeStampedModel, so make sure that you don’t record either ‘created’ or ‘modified’ fields.

Changes

11.09.2015 (0.2.5 release)

  • Renamed TimeStampedModel to AbstractTimeStampedModel.
  • Replaced monkey patched shortcut properties with RecordQueryset filters. Those shortcut properties are now deprecated.

09.20.2015

  • Support Python 3.4

06.13.2015

  • Following shortcut properties added to recording_model. All of properties below are ordinary django querysets.
    • records_in_hour: Records created in last recent hour.
    • records_in_day: Records created today.
    • records_in_week: Records created in this week.
    • records_in_month: Records created in this month.
    • records_in_year: Records created in this year.
  • Following shortcut properties providing resampled records has been added to recording_model. All of properties below are ordinary django querysets.
    • resampled_records_in_hour: Records created in last recent hour, resampled with minutes.
    • resampled_records_in_day: Records created today, resampled with hours.
    • resampled_records_in_week: Records created in this week, resamped with days.
    • resampled_records_in_month: Records created in this month, resampled with days.
    • resamped_records_in_year: Records created in this year, resampled with months.

05.18.2015

  • RecordedModelMixin added.
Release History

Release History

0.2.5

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.7

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-record-0.2.5.tar.gz (10.0 kB) Copy SHA256 Checksum SHA256 Source Nov 9, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting