Coder Social home page Coder Social logo

fakhrudin-mfm / django-versions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nowells/django-versions

0.0 0.0 0.0 395 KB

A django application to enable versioning of data stored in Django models.

Home Page: http://github.com/nowells/django-versions/

License: MIT License

Python 100.00%

django-versions's Introduction

django-versions

Overview

django-versions allows you to version the data stored in django models seamlessly. To get started all you need to do is to set VERSIONS_REPOSITORIES variable in your settings and configure the repositories you would like to use, then just subclass your Model from VersionsModel and start saving data:

from django.db import models
from versions.models import VersionsModel

class MyModel(VersionsModel):
    text = models.TextField()

Installation

Dependencies

  • Mercurial >= 1.5.2
  • Django == 1.1.X

Installing django-versions

If your are installing from source, you just need to run the following command from the base of the django-versions source tree:

python setup.py install

If you want to install the package without checking out the source you should run:

pip install django-versions

# OR if you don't have pip installed (you should definitely check out pip)
easy_install django-versions

For the time being, we need to patch Django to allow us to gain access to the related model from Manager classes. There is a patch included at the root of the source tree django.patch that includes the required changes. To patch django, go to the root of your checkout of django 1.1.X and run:

patch -p0 < /path/to/django-versions/django.patch

Add VERSIONS_REPOSITORIES to your settings file, pointing to the location where you would like django-versions to create and store your model history:

VERSIONS_REPOSITORIES = {
     'default': {
          'backend': 'versions.backends.hg',
          'local': '/path/to/my/projects/model/history',
          }
     }

Enabling Version Management

Install the VersionsMiddleware:

MIDDLEWARE_CLASSES = (
    ...
    'versions.middleware.VersionsMiddleware',
    ...
    )

Or handle enabling editing of Versioned models manually:

from versions.base import revision

@revision.commit_on_success
def my_editing_function(request):
    m = MyModel.objects.get(pk=1)
    m.save()


def my_other_editing_function(request):
    with revision:
        m = MyModel.objects.get(pk=1)
        m.save()

django-versions's People

Contributors

acdha avatar nowells avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.