Django: self.model_set not accesible in custom save() function

Viewed 20

I'm trying to make a custom save function that calculates some values and will store them in another Model to which a ManyToMany relationship exists. From what I can understand from the documentation, I should have a field_set way of accessing all the related objects. However, when I save here, I get the error 'Game' object has no attribute 'heat_set'

I don't see what I'm doing wrong here:

class Game(models.Model)
    heat = models.ManyToManyField(Heat)
    [...]

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)

        for heat in self.heat_set.all():
            [...]
0 Answers
Related