Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#14270 closed Cleanup/optimization (fixed)

ManyToMany manager classes should be cached

Reported by: Alex Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Normal Keywords:
Cc: real.human@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Right now they are created every time an m2m relationship is accessed, this class should be cached.

Attachments (3)

django-m2m-cleanup.diff (11.3 KB) - added by carljm 5 years ago.
patch from Alex Gaynor
14270-m2m-cleanup-r16522.diff (9.9 KB) - added by mrmachine 4 years ago.
Updated to apply cleanly on r16522.
14270_r16914.diff (10.4 KB) - added by lukeplant 4 years ago.
Updated for r16914, plus more tests

Download all attachments as: .zip

Change History (8)

comment:1 Changed 5 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 5 years ago by carljm

patch from Alex Gaynor

comment:2 Changed 4 years ago by julien

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:3 Changed 4 years ago by mrmachine

  • Cc real.human@… added
  • Easy pickings unset
  • UI/UX unset

Changed 4 years ago by mrmachine

Updated to apply cleanly on r16522.

comment:4 Changed 4 years ago by mrmachine

This change has the added benefit of exposing the related instance on the related objects manager for reverse relationships, which makes it possible to implement a userland update_or_create(), for example, and other methods that might need access to the related instance to work correctly or efficiently.

Thanks.

Changed 4 years ago by lukeplant

Updated for r16914, plus more tests

comment:5 Changed 4 years ago by lukeplant

  • Resolution set to fixed
  • Status changed from new to closed

In [16916]:

Fixed #14270 - related manager classes should be cached

Thanks to Alex Gaynor for the report and initial patch, and mrmachine for
more work on it.

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