Problem with a post_save signal?
class Book(models.Model):
room = models.ForeignKey(Room, on_delete=models.CASCADE, null=False)
library = models.ForeignKey(Library, on_delete=models.CASCADE, null=False)
created_at = models.DateTimeField(auto_now_add=True)
tracker = FieldTracker()
def update_service(sender, instance, **kwargs):
main_library = Library.object.get(id=1)
if not instance.library == library:
for book in instance.book_set.all():
book.delete()
post_save.connect(update_service, sender=Library)
lib/python3.7/site-packages/model_utils/tracker.py in set_saved_fields(self, fields)
106 self.saved_data = self.current()
107 else:
–> 108 self.saved_data.update(**self.current(fields=fields))
109
110 # preventing mutable fields side effects
AttributeError: ‘FieldInstanceTracker’ object has no attribute ‘saved_data’
2
Answers
I found the solution, I needed it to update some packages.
the first one was:
Then It also brought me some dependency with 2 other packages.
After I upgraded the libraries, the problem disappeared.
Also I did not need to add the fields to Tracker:
I let it the by default:
Just be careful with the libraries, because I spent a lot of times thinking that it was my code but in the end it was a library issue.
Set fields attribute of trackerfield.
Issue has been fixed in last version of package
Fields have to contains list of fields you want to track.
class is a reserved keyword. Be care !