Reversion with django-taggit
See original GitHub issueI’m not entirely sure whether this is your issue or a problem with django-taggit, but I figured I’d post it here (I’m also new to GitHub, so I apologize if I’m doing something wrong).
(If you haven’t used django-taggit: TaggedItem has a generic foreign key pointing to the tagged object and a foreign key to a Tag. Tags are basically just a slug. In the admin we see a text field that somehow gets converted into a bunch of TaggedItems when we save the instance.)
I’m trying to use reversion on a model with tags = TaggableManager(blank=True)
.
I’ve manually registered the Tag and TaggedItem tables using reversion.register(Tag)
and reversion.register(TaggedItem)
. I registered my model using reversion.register(MyModel, follow=["tags"])
But in the admin, the Edit / History / Revert page always shows the tags of the newest version, no matter which datetime I click on in the history list.
The database table reversion_version seems to be OK. Taggit chooses to remove all tags and recreate relink them when you save in the admin, so if I add a tag to an object that has one tag I get the following rows in the revision table:
(I’m assuming mode 0 = add, mode 1 = update, mode 2 = remove)
- taggeditem for old_tag removed
- taggeditem for old_tag added
- taggeditem for new_tag added
- new_tag added
- old_tag updated (I didn’t actually change the tag itself, but I think this would cause problems.)
- myobject updated
This seems good to me. I’m guessing it isn’t actually a revision problem, but a VersionAdmin / TaggableManager issue. I don’t understand Django well enough to really understand how TaggableManager affects the model or how VersionAdmin populates the admin form, so this was about as far as I could go.
Issue Analytics
- State:
- Created 12 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
The comment is generated by
django.contrib.admin
, not django-reversion. I don’t know why it chooses to create that erroneous comment.Saving the model will always save a revision, even if nothing has changed. That’s expected behaviour. Anything else generates race conditions in the database, and incurs a performance overhead.
Closing for lack of activity.