Using functions in models to dynamically fill fields on object creation in Django
- by danspants
Within Django, can a function local to a model be called on object creation to dynamically fill a field?
class someModel(models.Model):
id = models.FloatField(primary_key=True, default=generate_id())
def generate_id(self):
newId=time.time()
return newId
So far I haven't had any luck with getting it to work or with locating documentation that covers it.