question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reversion with django-taggit

See original GitHub issue

I’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:closed
  • Created 12 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
etianencommented, Aug 22, 2016

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.

0reactions
etianencommented, Nov 28, 2016

Closing for lack of activity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does not work with django-taggit · Issue #10 - GitHub
Django-reversion-compare seems to have a good deal of problems with django-taggit; perhaps it's due to django-taggit not being up-to-date ...
Read more >
The API — django-taggit 1.3.0 documentation - Read the Docs
django -taggit ... be used in forms (including the admin). through – The through model, see Customizing taggit for more information. ... Revision...
Read more >
Welcome to django-taggit's documentation! — django-taggit ...
django -taggit is a reusable Django application designed to make adding tagging to your project easy and fun. django-taggit works with Django 2.2+...
Read more >
External Applications — django-taggit 1.3.0 documentation
django -taggit-helpers: Makes it easier to work with admin pages of models associated with taggit tags by adding helper classes: TaggitCounter , TaggitListFilter ......
Read more >
Changelog — django-taggit 1.3.0 documentation
As a reminder, custom tag models can easily customize slugification behavior by overriding the slugify method to your business needs. `` Drop Django...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found