#29413: `QuerySet._extract_model_params` can/should be enchanced to support lazy defaults -------------------------------------+------------------------------------- Reporter: Viktor | Owner: nobody Danyliuk | Type: | Status: new Cleanup/optimization | Component: Database | Version: 2.0 layer (models, ORM) | Keywords: QuerySet Severity: Normal | get_or_create update_or_create lazy Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- I wish to have ability to write something like this: {{{ from django.utils.functional import lazy
obj, created = model.objects.select_related('user').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`. -- Ticket URL: <https://code.djangoproject.com/ticket/29413> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.250f11fd18f2206d3fcca2de74f22994%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.