[Fixed]-Django Model – Incrementing Version Number like Grails

1👍

overwrite the save method of the model

class Increment(models.Model):
    # data you want to store

    # the version bit
    version = Models.IntegerField(default=0)

    def save(self, *args, **kwargs):
        self.version = self.version + 1
        super(Model, self).save(*args, **kwargs)

Leave a comment