0
I have the following models in my Django app:
class Tag(models.Model):
name = models.CharField(max_length=150)
description = models.TextField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.name
class Meta:
db_table = 'tags'
ordering = ('name', )
class Question(models.Model):
title = models.CharField(max_length=300)
text = models.TextField()
user = models.ForeignKey(User, on_delete=models.DO_NOTHING, related_name='questions')
tags = models.ManyToManyField(Tag, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
In the case, Question
has N
relationships with N
tags. Suppose in Question 1 I have a relationship with tags 1, 2 and 3, as I would to remove all tags related to Question?
Example:
question = Question.objects.get(pk=1)
# Quero desassociar todas as tags dessa questão