Union and Intersect in Django

前端 未结 4 848
面向向阳花
面向向阳花 2020-12-24 12:17
class Tag(models.Model):
  name = models.CharField(maxlength=100)

class Blog(models.Model):
  name = models.CharField(maxlength=100)
  tags =  models.ManyToManyFiel         


        
4条回答
  •  一个人的身影
    2020-12-24 12:47

    Please don't reinvent the wheel and use django-tagging application which was made exactly for your use case. It can do all queries you describe, and much more.

    If you need to add custom fields to your Tag model, you can also take a look at my branch of django-tagging.

提交回复
热议问题