-
-
Notifications
You must be signed in to change notification settings - Fork 623
Open
Labels
Description
I suppose that django-taggit and django-simple-history can work together, but can't figure it out, and can't find a full working example :(
I would like to enable history on the m2m relationship that django-taggit adds to my model, but the TaggableManager
does not seem to have the necessary fields (?).
Using the following model definition:
from simple_history.models import HistoricalRecords
from taggit.managers import TaggableManager
class MyModel(models.Model):
tags = TaggableManager()
history = HistoricalRecords(m2m_fields=[tags])
I get this error:
File "/Users/mathieu/Code/Perso/collect/.venv/lib/python3.12/site-packages/simple_history/models.py", line 794, in get_m2m_fields_from_model
return [getattr(model, field_name).field for field_name in field_names]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_TaggableManager' object has no attribute 'field'
Although it looks very similar to what django-simple-history shows in the docs:
class Category(models.Model):
name = models.CharField(max_length=200)
class Poll(models.Model):
question = models.CharField(max_length=200)
categories = models.ManyToManyField(Category)
history = HistoricalRecords(m2m_fields=[categories])
What makes the TaggableManager
different from a normal ManyToMany
field?
What could I do to "trick" simple_history's HistoricalRecords m2m fields inspection?
Thank you for your support and great lib 🙏
Related #501
l1b3r and puglet5