M.Izzat
M.Izzat

Reputation: 1166

Django MonitorField() not working with Foreign Key if when condition is added

Greeting, as mention in the question, my MonitorField stop updating the date when I add a when condition in it, below is my code :

class A(models.Model):

    name = models.CharField(max_length=50, unique=True)

    def __str__(self):
        return self.name

class B(models.Model):
 status = models.ForeignKey(A, on_delete=models.CASCADE, default=4, null=True)
 monitor = fields.MonitorField(monitor='status', when=[1])

Upvotes: 1

Views: 489

Answers (1)

Vaibhav
Vaibhav

Reputation: 1244

You missed comma between monitor and when field

monitor = fields.MonitorField(monitor='status', when=[1])

Check this issue of django-model-utils on github if above doesnt work LINK

Upvotes: -1

Related Questions