0

I have a model that has 10000 objects and I want to add a new field to it that equals the result of a function acting on another field

class MyModel(models.Model):
    id = models.CharField(max_length=255)
    field1 = models.CharField(max_length=255)
    new_field = models.CharField(max_length=255,default=my_func(self.field1))

how can I achieve this? to provide a default value for every object in my DB based upon one of its fields

Ammar rady
  • 136
  • 2
  • 13

0 Answers0