Skip to content

Commit

Permalink
Fix issue with missing tags on MySQL
Browse files Browse the repository at this point in the history
Had to change the base class for `TaggedItem` from `GenericTaggedItemBase` to `GenericUUIDTaggedItemBase`, to get the django-taggit machinery to do a UUID-based comparison of the prefetched "tags". Without that the prefetched values weren't matching correctly, and were returning empty. (See: jazzband/django-taggit#663)
  • Loading branch information
jathanism committed Jun 8, 2021
1 parent 425ba44 commit 6fe817e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nautobot/extras/models/tags.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db import models
from django.urls import reverse
from django.utils.text import slugify
from taggit.models import TagBase, GenericTaggedItemBase
from taggit.models import TagBase, GenericUUIDTaggedItemBase

from nautobot.extras.models import ChangeLoggedModel, CustomFieldModel
from nautobot.extras.models.relationships import RelationshipModel
Expand Down Expand Up @@ -47,7 +47,7 @@ def to_csv(self):
return (self.name, self.slug, self.color, self.description)


class TaggedItem(BaseModel, GenericTaggedItemBase):
class TaggedItem(BaseModel, GenericUUIDTaggedItemBase):
tag = models.ForeignKey(to=Tag, related_name="%(app_label)s_%(class)s_items", on_delete=models.CASCADE)
object_id = models.UUIDField()

Expand Down

0 comments on commit 6fe817e

Please sign in to comment.