Пример #1
0
class Pet(models.Model):
    name = models.CharField(max_length=50)

    tags = TaggableManager()

    def __str__(self):
        return self.name
Пример #2
0
class BlankTagModel(models.Model):
    name = models.CharField(max_length=50)

    tags = TaggableManager(blank=True)

    def __str__(self):
        return self.name
Пример #3
0
class OfficialPet(models.Model):
    name = models.CharField(max_length=50)

    tags = TaggableManager(through=OfficialThroughModel)

    def __str__(self):
        return self.name
Пример #4
0
class CustomPKPet(models.Model):
    name = models.CharField(max_length=50, primary_key=True)

    tags = TaggableManager(through=TaggedCustomPK)

    def __str__(self):
        return self.name
Пример #5
0
class DirectTrackedPet(models.Model):
    name = models.CharField(max_length=50)

    tags = TaggableManager(through=TaggedTrackedPet)

    def __str__(self):
        return self.name
Пример #6
0
class DirectFood(models.Model):
    name = models.CharField(max_length=50)

    tags = TaggableManager(through="TaggedFood")

    def __str__(self):
        return self.name
Пример #7
0
class UUIDPet(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    name = models.CharField(max_length=50)

    tags = TaggableManager(through="UUIDTaggedItem")
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.name

    class Meta:
        # With a UUIDField pk, objects are not always ordered by creation time. So explicitly set ordering.
        ordering = ["created_at"]
Пример #8
0
class Tag(models.Model):
    name = models.CharField(unique=True, max_length=100)
    slug = models.SlugField(unique=True, max_length=100)

    objects = ExtendedManager()
    tags = TaggableManager()

    def __str__(self):
        return f"{self.name}"

    def save(self, *args, **kwargs):
        self.slug = slugify(self.name)
        super().save(*args, **kwargs)
Пример #9
0
class MultiInheritanceFood(BaseFood):
    tags = TaggableManager(through=MultiInheritanceLazyResolutionFoodTag)

    def __str__(self):
        return self.name
Пример #10
0
class Name(models.Model):
    tags = TaggableManager(related_name="a_unique_related_name")
Пример #11
0
class MultipleTagsGFK(models.Model):
    tags1 = TaggableManager(related_name="tagsgfk1")
    tags2 = TaggableManager(through=ThroughGFK, related_name="tagsgfk2")
Пример #12
0
class Parent(models.Model):
    tags = TaggableManager()
Пример #13
0
class CustomManager(models.Model):
    class Foo:
        def __init__(*args, **kwargs):
            pass

    tags = TaggableManager(manager=Foo)
Пример #14
0
class Article(models.Model):
    title = models.CharField(max_length=100)

    tags = TaggableManager(through=ArticleTaggedItem)
Пример #15
0
class Media(models.Model):
    tags = TaggableManager()

    class Meta:
        abstract = True
Пример #16
0
class MutipleTags(models.Model):
    tags1 = TaggableManager(through=Through1, related_name="tags1")
    tags2 = TaggableManager(through=Through2, related_name="tags2")