Opened 5 years ago

Closed 5 years ago

Last modified 4 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: UI/UX:

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 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

This is a dupe of #12247.

comment:2 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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