Opened 7 years ago
Last modified 6 years ago
#29413 closed Cleanup/optimization
`QuerySet._extract_model_params` can/should be enchanced to support lazy defaults — at Version 2
Reported by: | Viktor Danyliuk | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 2.0 |
Severity: | Normal | Keywords: | QuerySet get_or_create update_or_create lazy |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
I wish to have ability to write something like this:
from django.utils.functional import lazy obj, created = model.objects.get_or_create( key=jwt, defaults=lazy(self.get_defaults_for_model, dict)(jwt) )
But at the moment _extract_model_params
prepare defaults before it's realy needed.
I think _extract_model_params
should be separated to _prepare_model_lookup
and _prepare_model_params
.
So it will be possible to call _prepare_model_params
when model.DoesNotExist
or even inside _create_object_from_params
.
Change History (2)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.