Schedule `function` to be called once `model` and all `related_models` have been imported and registered with the app registry. `function` will be called with the newly-loaded model classes as its positional arguments, plus any optional keyword arguments. The `model` argument m
(function, model, *related_models, **kwargs)
| 75 | |
| 76 | |
| 77 | def lazy_related_operation(function, model, *related_models, **kwargs): |
| 78 | """ |
| 79 | Schedule `function` to be called once `model` and all `related_models` |
| 80 | have been imported and registered with the app registry. `function` will |
| 81 | be called with the newly-loaded model classes as its positional arguments, |
| 82 | plus any optional keyword arguments. |
| 83 | |
| 84 | The `model` argument must be a model class. Each subsequent positional |
| 85 | argument is another model, or a reference to another model - see |
| 86 | `resolve_relation()` for the various forms these may take. Any relative |
| 87 | references will be resolved relative to `model`. |
| 88 | |
| 89 | This is a convenience wrapper for `Apps.lazy_model_operation` - the app |
| 90 | registry model used is the one found in `model._meta.apps`. |
| 91 | """ |
| 92 | models = [model] + [resolve_relation(model, rel) for rel in related_models] |
| 93 | model_keys = (make_model_tuple(m) for m in models) |
| 94 | apps = model._meta.apps |
| 95 | return apps.lazy_model_operation(partial(function, **kwargs), *model_keys) |
| 96 | |
| 97 | |
| 98 | class RelatedField(FieldCacheMixin, Field): |
no test coverage detected