Skip to content

3.15 regression: UpdateModelMixin breaks views using Manager objects as queryset #9319

@peterthomassen

Description

@peterthomassen
  • Since Re-prefetch related objects after updating #8043, UpdateModelMixin.update() accesses the queryset's _prefetch_related_lookups attribute.
  • Manager objects don't have this attribute.
  • This causes an exception when the queryset is, e.g., a RelatedManager:
     def get_queryset(self):
         return self.user.somerelated_set

Notes:

  • get_queryset() is not expected to return a QuerySet. This is explicitly stated in get_queryset()'s docstring.
  • In fact, that docstring implies that there is no expectation that there is a _prefetch_related_lookups attribute.
  • My particular instance of the problem could be fixed on the application side by adding .all(). However, that would cause early evaluation of the queryset before filtering. That's not an option; SQL queries should run only once all WHERE conditions have been applied.

This is a regression that simply breaks stuff that has been working with the stable API. The change should be reverted.

(This is similar to #9306, but not the same.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy