Skip to content

Monitor field fails to update while object creation even if the when condition matches #401

@aravindacreoit

Description

@aravindacreoit

Problem

Monitor field does not get updated while the creation of the model object even if matches the when condition

from model_utils.fields import MonitorField, StatusField

class Article(models.Model):
STATUS = Choices('draft', 'published')
status = StatusField()
published_at = MonitorField(monitor='status', when=['published'])

Here whenever we create Article object with status = 'published', published_at does not get updated with timestamp.

BUT when we change status of an already existing Article from draft to published, published_at gets updated with timestamp value.

ie monitor field gets updated only when an object is updated, not when an object is created.

Environment

  • Django Model Utils version: 3.1.2
  • Django version: 2.2
  • Python version: 3.6 +

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions