1π
β
One option is to override your save method to apply this before itβs saved.
class Entry(models.Model):
created = models.DateTimeField(auto_now_add=True)
title = models.CharField(max_length=50)
content = models.TextField()
# Need to specify it as blank=True here or
# in the form so it can be ignored when the form is cleaned
hashval = models.BigIntegerField(blank=True)
def save(self, *args, **kwargs):
self.hashval = abs(hash(self.title))
return super(Entry, self).save(*args, **kwargs)
π€schillingt
Source:stackexchange.com