Opened 15 years ago

Closed 15 years ago

Last modified 13 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: dev
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

Description

model:

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?!')
1
>>> [p.name for p in Party.objects.all()]
[u'What?!']

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

Change History (2)

comment:1 by Karen Tracey, 15 years ago

Resolution: duplicate
Status: newclosed

This is a dupe of #12247.

comment:2 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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