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.

Multiple TaggableManager() fields in single model

See original GitHub issue

When trying to create a model like:

class Test(models.Model):
    tag1 = TaggableManager()
    tag2 = TaggableManager()

It gives the error: ValueError: You can’t have two TaggableManagers with the same through model.

How can I allow multiple taggit fields for a single model? Thanks

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:22 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
thenewguycommented, Jun 9, 2021

Laughing at myself - read the error message.

class Operation(models.Model):
    add_segments = TaggableManager(through=TaggedAddOperationSegment, blank=True, related_name='foo')
    remove_segments = TaggableManager(through=TaggedRemoveOperationSegment, blank=True, related_name='bar')

1reaction
rtpgcommented, Apr 14, 2021

OK this topic definitely seems worthy of some FAQ-ing

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to have two tag fields i.e. two Taggable Managers in the ...
I would try to implement it like this. from django.db import models from taggit.managers import TaggableManager from taggit.models import ...
Read more >
How to have multiple tag fields with Taggit in one model?
I tried to add admin_tags = TaggableManager() but it says that two Taggable Managers can't exist. How can I fix this? Models.py.
Read more >
How to have two tag fields i.e. two Taggable Managers in the ...
I would try to implement it like this. from django.db import models from taggit.managers import TaggableManager from taggit.models import TaggedItemBase, ...
Read more >
Customizing taggit — django-taggit 1.3.0 documentation
Model ): # ... fields here tags = TaggableManager(through=TaggedFood). Once this is done, the API works the same as for GFK-tagged models.
Read more >
django-taggit - Read the Docs
Model ):. # ... fields here tags = TaggableManager() ... One important thing to note is that you cannot include a TaggableManager in ......
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