MCPcopy
hub / github.com/django/django / remove_model

Method remove_model

django/db/migrations/state.py:128–142  ·  view source on GitHub ↗
(self, app_label, model_name)

Source from the content-addressed store, hash-verified

126 self.reload_model(*model_key)
127
128 def remove_model(self, app_label, model_name):
129 model_key = app_label, model_name
130 del self.models[model_key]
131 if self._relations is not None:
132 self._relations.pop(model_key, None)
133 # Call list() since _relations can change size during iteration.
134 for related_model_key, model_relations in list(self._relations.items()):
135 model_relations.pop(model_key, None)
136 if not model_relations:
137 del self._relations[related_model_key]
138 if "apps" in self.__dict__: # hasattr would cache the property
139 self.apps.unregister_model(*model_key)
140 # Need to do this explicitly since unregister_model() doesn't clear
141 # the cache automatically (#24513)
142 self.apps.clear_cache()
143
144 def rename_model(self, app_label, old_name, new_name):
145 # Add a new model.

Callers 3

rename_modelMethod · 0.95
state_forwardsMethod · 0.80
test_remove_modelMethod · 0.80

Calls 4

unregister_modelMethod · 0.80
popMethod · 0.45
itemsMethod · 0.45
clear_cacheMethod · 0.45

Tested by 1

test_remove_modelMethod · 0.64