Skip to content

Wrong calculation of changes when creating a new record with DateTimeField #770

@ts-mk

Description

@ts-mk

This is a follow-up to issue #750. While v3.3.0 fixed the issue for the originally reported field TimeField, there is now a problem with a DateTimeField.

Environment

Python: 3.12
django-auditlog: 3.3.0
AUDITLOG_STORE_JSON_CHANGES: False

Model

class TestModel(Model):
    text = models.CharField(default="abc")
    datetime = models.DateTimeField(null=True, blank=True)

Steps

  1. Create and save a NEW instance of the model with text="abc", datetime=None.
  2. When old_value and new_value get calculated for the field datetime, their values are "None" (old_value) and None (new_value), which means that they do not match and the field datetime gets added to the diff variable as (None, None).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions