GithubHelp home page GithubHelp logo

wd5 / 1-django-versioning Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emacsway/django-versioning

0.0 2.0 0.0 144 KB

Version any object in Django, stores only diff, not content copy.

License: BSD 3-Clause "New" or "Revised" License

1-django-versioning's Introduction

Django-Versioning

Django-versioning allows you to version the data stored in django models, and stores only diff, not content copy.

Supports all field types excepts ManyToMany (currently).

Forked from https://github.com/brosner/django-versioning

Usage

settings.py:

MIDDLEWARE_CLASSES = [
    # ...
    "versioning.middleware.VersioningMiddleware",
    # ...
]
# ...
INSTALLED_APPS = [
    # ...
   'versioning',  # Should be after apps with versioned models
    # ...
]

wiki/models.py:

from django.db import models
from django.contrib.auth.models import User
import versioning

class Article(models.Model):
    title = models.CharField()
    body = models.TextField()
    is_active = models.BooleanField()
    weight = models.IntegerField(blank=True, null=True)
    creator = models.ForeignKey(User, blank=True, null=True)

    class Meta:
        permissions = (
            ("wiki.browse_revision_article", "Can browse revisions"),
            ("wiki.reapply_revision_article", "Can repply revision"),
        )

versioning.register(
    Article,
    ['title', 'body', 'is_active', 'weight', 'creator', ]
)

wiki/templates/wiki/article_detail.html:

...
<a href="{% url versioning_revision_list content_type=contenttype_id object_id=article.pk %}">View the list of revisions.</a>
...

If you have already existent content, to create a first revision, simple run:

./manage.py versioning_setup wiki.Article -f

You can also view revisions in admin, by clicking "History" button on change object page.

1-django-versioning's People

Contributors

brosner avatar emacsway avatar uruz avatar

Watchers

James Cloos avatar wd5 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.