MCPcopy
hub / github.com/django/django / clear_cache

Method clear_cache

django/apps/registry.py:370–386  ·  view source on GitHub ↗

Clear all internal caches, for methods that alter the app registry. This is mostly used in tests.

(self)

Source from the content-addressed store, hash-verified

368 self.clear_cache()
369
370 def clear_cache(self):
371 """
372 Clear all internal caches, for methods that alter the app registry.
373
374 This is mostly used in tests.
375 """
376 self.get_swappable_settings_name.cache_clear()
377 # Call expire cache on each model. This will purge
378 # the relation tree and the fields cache.
379 self.get_models.cache_clear()
380 if self.ready:
381 # Circumvent self.get_models() to prevent that the cache is
382 # refilled. This particularly prevents that an empty value is
383 # cached while cloning.
384 for app_config in self.app_configs.values():
385 for model in app_config.get_models(include_auto_created=True):
386 model._meta._expire_cache()
387
388 def lazy_model_operation(self, function, *model_keys):
389 """

Callers 15

populateMethod · 0.95
register_modelMethod · 0.95
set_available_appsMethod · 0.95
unset_available_appsMethod · 0.95
set_installed_appsMethod · 0.95
unset_installed_appsMethod · 0.95
user_model_swappedFunction · 0.45
remove_modelMethod · 0.45
bulk_updateMethod · 0.45
register_modelMethod · 0.45
setUpMethod · 0.45

Calls 3

_expire_cacheMethod · 0.80
valuesMethod · 0.45
get_modelsMethod · 0.45

Tested by 15

setUpMethod · 0.36
test_clear_cacheMethod · 0.36
tearDownMethod · 0.36
setUpMethod · 0.36
tearDownMethod · 0.36
setUpClassMethod · 0.36
tearDownMethod · 0.36
tearDownMethod · 0.36
setUpClassMethod · 0.36