Reputation: 21
Here is a model with multiple tags in it. How do I retrieve data from tags_en? tags.names() works well but not tags_en.names() nor tags_en.all()
from taggit.models import GenericUUIDTaggedItemBase, TaggedItemBase, TagBase
from taggit_selectize.managers import TaggableManager
class UUIDTaggedItem(GenericUUIDTaggedItemBase, TaggedItemBase):
class Meta:
verbose_name = _("Tag")
verbose_name_plural = _("Tags")
class BaseTag (TagBase):
pass
class UUIDTaggedItemEn (GenericUUIDTaggedItemBase, TaggableManager):
tag = models.ForeignKey(BaseTag)
class Item(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
tags = TaggableManager(blank=True, through=UUIDTaggedItem)
tags_en = TaggableManager(blank=True, through=UUIDTaggedItemEn)
Error message is:
FieldError at /admin/item/item/
Cannot resolve keyword 'None' into field. Choices are: category, id, item, name, slug, taggroup, uuidtaggeditemen
Upvotes: 2
Views: 1250
Reputation: 2570
first you should add a Manager attribute to the other class like
class UUIDTaggedItemEn (GenericUUIDTaggedItemBase, TaggableManager):
tag = models.ForeignKey(BaseTag)
objects = = models.Manager()
then you can call the use filter like
tags_en.objects.filter(id=...)
tags_en.objects.all()
the problem is with multiple taggablemanagers you are calling them though other classes and when ou went to receive the objects you need to call those classes. Hope that helped if not leave a comment
Upvotes: 2