#26706: ManyToMany clear doesn't clear the items from the object but deletes
from
db
----------------------------------------------+----------------------------
Reporter: cosmosgenius | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords: manytomany,
| m2m, clear
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+----------------------------
{{{
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 "[ ]"
--
Ticket URL: <https://code.djangoproject.com/ticket/26706>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/055.e0c044b4b37cf9b7d5465a024f5dd867%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.