[Answer]-How to make something editable by everybody while keeping track of history?

1👍

There is an easy way to do it but you’ll have to drop the uniqueness of the SlugField.

class Post(models.Model):
    user = models.ForeignKey('auth.User')
    slug = models.SlugField(unique=False)
    subject = models.CharField(max_length=255)
    body = models.TextField()
    version = models.DateTimeField(auto_now_add=True, auto_now=True)

What you do in your view is simply pull the instances with the same slug and order them by date, the latest date will obviously be the current version.

Then in your template, you’ll use the id field as a get variable, the redirect url for a version should look like this:
http://someurl.com/this-unique-post?v=3

Where 3 is the id of that post’s version, then if you want to make, say the version with id=3 as the current version, you’ll just save/update it again!

Hope this helps!

0👍

There are django apps for that. for example: https://github.com/etianen/django-reversion

Leave a comment