Django: remove all m2m relations

Posted by pistacchio on Stack Overflow See other posts from Stack Overflow or by pistacchio
Published on 2010-05-26T14:54:50Z Indexed on 2010/05/26 15:01 UTC
Read the original article Hit count: 219

Filed under:

Hi,

if I have two simple models:

class Tag(models.Model):
    name = models.CharField(max_length=100)

class Post(models.Model):
    title = models.CharField(max_length=100)
    tags = models.ManyToManyField(Tag, blank=True)

given a Post object with a number of Tags added to it, I know hot to remove any of them, but how to do a mass remove (remove all)? Thanks

© Stack Overflow or respective owner

Related posts about django