#29413: `QuerySet._extract_model_params` can/should be enchanced to support lazy
defaults
-------------------------------------+-------------------------------------
Reporter: Viktor Danyliuk | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: QuerySet | Triage Stage:
get_or_create update_or_create | Unreviewed
lazy |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Viktor Danyliuk:
Old description:
> 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's will be possible to call `_prepare_model_params` when
> `model.DoesNotExist` or even inside `_create_object_from_params`.
New description:
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`.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/29413#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.b3ab1f9d3f3e8db942f506d31a59190e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.