Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#13228 closed (duplicate)

queryset.update() on custom manager ignores all filter

Reported by: flytwokites Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: update
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



class Party(models.Model):
    name = models.CharField(max_length=50)
    is_company = models.BooleanField()

class CompanyManager(models.Manager):

    def get_query_set(self):
        return super(CompanyManager, self).get_query_set().filter(is_company=True)

class Company(Party):
    objects = CompanyManager()
    class Meta:
        proxy = True

show bug:

>>> Company.objects.create(name='GlideTools')
>>> Company.objects.filter(name='M$')
>>> Company.objects.filter(name='M$').update(name='What?!')
>>> [ for p in Party.objects.all()]

The update() updates all objects, All filters on it is ignored!

Change History (2)

comment:1 Changed 9 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

This is a dupe of #12247.

comment:2 Changed 8 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top