def check_model_schema(sender, instance, **kwargs): """ Check that the schema being used is the most up-to-date. Called on pre_save to guard against the possibility of a model schema change between instance instantiation and record save. """ if not is_current_model(sender): raise OutdatedModelError(f"model {sender.__name__} has changed")
def test_is_current_model(self, model_schema): model = model_schema.as_model() assert utils.is_current_model(model) cache.update_last_modified(model_schema.model_name) assert not utils.is_current_model(model)
def get_model(self): registered = self.get_registered_model() if registered and is_current_model(registered): return registered return self.make_model()
def test_related_model_schema_notified_on_field_update( self, model_schema, field_schema): model = model_schema.as_model() assert utils.is_current_model(model) field_schema.update_last_modified() assert not utils.is_current_model(model)