I am new to django and trying to understand the capabilities of django models. I stumbled across Model managers and understand that they can be used to perform customized queries and I understand how they serve that function.
But what if I wanted to create a new object but under a specific set of guidelines. For example let's say I had a model as such:
#models.py
class TestModel(model.Model):
num = models.IntegerField(default=5)
Now if I create a new object without specifying the value of num it will set its default equal to 5. But is it possible to have a creation function within the model that would give it another value. For example what if I wanted the value to be a random number between 1 and 100. I know that I could always run that function and then set the num field equal to its output and then create the new object, but I want to have that function run within the model and execute just by calling TestModel(). Is this possible?