(self, real_apps, models, ignore_swappable=False)
| 627 | """ |
| 628 | |
| 629 | def __init__(self, real_apps, models, ignore_swappable=False): |
| 630 | # Any apps in self.real_apps should have all their models included |
| 631 | # in the render. We don't use the original model instances as there |
| 632 | # are some variables that refer to the Apps object. |
| 633 | # FKs/M2Ms from real apps are also not included as they just |
| 634 | # mess things up with partial states (due to lack of dependencies) |
| 635 | self.real_models = [] |
| 636 | for app_label in real_apps: |
| 637 | app = global_apps.get_app_config(app_label) |
| 638 | for model in app.get_models(): |
| 639 | self.real_models.append(ModelState.from_model(model, exclude_rels=True)) |
| 640 | # Populate the app registry with a stub for each application. |
| 641 | app_labels = {model_state.app_label for model_state in models.values()} |
| 642 | app_configs = [ |
| 643 | AppConfigStub(label) for label in sorted([*real_apps, *app_labels]) |
| 644 | ] |
| 645 | super().__init__(app_configs) |
| 646 | |
| 647 | # These locks get in the way of copying as implemented in clone(), |
| 648 | # which is called whenever Django duplicates a StateApps before |
| 649 | # updating it. |
| 650 | self._lock = None |
| 651 | self.ready_event = None |
| 652 | |
| 653 | self.render_multiple([*models.values(), *self.real_models]) |
| 654 | |
| 655 | # There shouldn't be any operations pending at this point. |
| 656 | from django.core.checks.model_checks import _check_lazy_references |
| 657 | |
| 658 | ignore = ( |
| 659 | {make_model_tuple(settings.AUTH_USER_MODEL)} if ignore_swappable else set() |
| 660 | ) |
| 661 | errors = _check_lazy_references(self, ignore=ignore) |
| 662 | if errors: |
| 663 | raise ValueError("\n".join(error.msg for error in errors)) |
| 664 | |
| 665 | @contextmanager |
| 666 | def bulk_update(self): |
nothing calls this directly
no test coverage detected