Skip to content
Snippets Groups Projects
Verified Commit ba5f9a9f authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Use raw field name instead of relation name for field tracker

django-model-utils' documentation states that using the relation is not stable in all situations.
parent 5f92401f
No related branches found
No related tags found
1 merge request!948Resolve "'FieldInstanceTracker' object has no attribute 'saved_data'"
Pipeline #52845 passed
......@@ -9,6 +9,11 @@ and this project adheres to `Semantic Versioning`_.
Unreleased
----------
Fixed
~~~~~
* Apps which track changes to models didn't work.
`2.7.2`_ - 2022-01-31
---------------------
......
......@@ -316,7 +316,7 @@ class Person(ExtensibleModel):
def initials(self):
return f"{self.first_name[0]}{self.last_name[0]}".upper()
user_info_tracker = FieldTracker(fields=("first_name", "last_name", "email", "user"))
user_info_tracker = FieldTracker(fields=("first_name", "last_name", "email", "user_id"))
@property
def member_of_recursive(self) -> QuerySet:
......@@ -341,9 +341,9 @@ class Person(ExtensibleModel):
super().save(*args, **kwargs)
if self.pk is None or bool(changed):
if "user" in changed:
if "user_id" in changed:
# Clear groups of previous Django user
previous_user = changed["user"]
previous_user = changed["user_id"]
if previous_user is not None:
get_user_model().objects.get(pk=previous_user).groups.clear()
......@@ -355,7 +355,7 @@ class Person(ExtensibleModel):
self.user.email = self.email
self.user.save()
if "user" in changed:
if "user_id" in changed:
# Synchronise groups to Django groups
for group in self.member_of.union(self.owner_of.all()).all():
group.save(force=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment