Opened 8 years ago

Last modified 6 years ago

#24215 closed Cleanup/optimization

Refactor of lazy model operations — at Version 1

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

Description (last modified by Alex Hill)

I dealt with add_lazy_relation() a few months ago working on Mezzanine and I thought it could use some detangling.

Now that the list of pending operations is stored in the Apps class, it makes sense to put the related methods on that class as well. Running a function when a model is loaded seems an appropriate job for the app registry object.

I've introduced a more generic API, whereby a user-supplied function can be called once any number of models are ready, with those freshly-loaded models as its arguments (plus optional kwargs), a helper function for related models, and the old add_lazy_relation() reimplemented in terms of the new API with a deprecation warning.

Pull request at https://github.com/django/django/pull/3984

Change History (1)

comment:1 Changed 8 years ago by Alex Hill

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top