MCPcopy
hub / github.com/django/django / get_objects

Method get_objects

django/db/backends/base/creation.py:146–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144
145 # Iteratively return every object for all models to serialize.
146 def get_objects():
147 from django.db.migrations.loader import MigrationLoader
148
149 loader = MigrationLoader(self.connection)
150 for app_config in apps.get_app_configs():
151 if (
152 app_config.models_module is not None
153 and app_config.label in loader.migrated_apps
154 and app_config.name not in settings.TEST_NON_SERIALIZED_APPS
155 ):
156 for model in app_config.get_models():
157 if model._meta.can_migrate(
158 self.connection
159 ) and router.allow_migrate_model(self.connection.alias, model):
160 queryset = model._base_manager.using(
161 self.connection.alias,
162 ).order_by(model._meta.pk.name)
163 chunk_size = (
164 2000 if queryset._prefetch_related_lookups else None
165 )
166 yield from queryset.iterator(chunk_size=chunk_size)
167
168 # Serialize to a string
169 out = StringIO()

Callers

nothing calls this directly

Calls 8

MigrationLoaderClass · 0.90
get_app_configsMethod · 0.80
can_migrateMethod · 0.80
order_byMethod · 0.80
get_modelsMethod · 0.45
allow_migrate_modelMethod · 0.45
usingMethod · 0.45
iteratorMethod · 0.45

Tested by

no test coverage detected