﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26706	ManyToMany clear doesn't clear the items from the object but deletes from db	Sharat M R	nobody	"{{{

class Media(models.Model):
    name = models.CharField(max_length=100)


class Tag(models.Model):
    tag = models.CharField(max_length=100)
    medias = models.ManyToManyField(Media)

    def __unicode__(self):
        return self.tag
}}}

Assume tag object below already has three items of Media model in medias which are saved in db. [m1, m2, m3].

{{{
tag = Tag.objects.get(id=1)
tag.medias.clear()
print(tag.medias.all())
}}}

The above code prints all the three [m1, m2, m3]. Fetching the tag again using get and printing givens an empty list ""[ ]"""	Bug	new	Database layer (models, ORM)	1.8	Normal		manytomany, m2m, clear		Unreviewed	0	0	0	0	0	0
