'Find any renamed models, generate the operations for them, and remove
the old entry from the model lists. Must be run before other
model-level generation.'

def generate_renamed_models(self):

    self.renamed_models = {}
    self.renamed_models_rel = {}
    added_models = set(self.new_model_keys).difference(self.old_model_keys)
    for (app_label, model_name) in sorted(added_models):
        model_state = self.to_state.models[(app_label, model_name)]
        model_fields_def = self.only_relation_agnostic_fields(model_state.fields)
        removed_models = set(self.old_model_keys).difference(self.new_model_keys)
        for (rem_app_label, rem_model_name) in removed_models:
            if (rem_app_label == app_label):
                rem_model_state = self.from_state.models[(rem_app_label, rem_model_name)]
                rem_model_fields_def = self.only_relation_agnostic_fields(rem_model_state.fields)
                if (model_fields_def == rem_model_fields_def):
                    if self.questioner.ask_rename_model(rem_model_state, model_state):
                        self.add_operation(app_label, operations.RenameModel(old_name=rem_model_state.name, new_name=model_state.name))
                        self.renamed_models[(app_label, model_name)] = rem_model_name
                        renamed_models_rel_key = ('%s.%s' % (rem_model_state.app_label, rem_model_state.name))
                        self.renamed_models_rel[renamed_models_rel_key] = ('%s.%s' % (model_state.app_label, model_state.name))
                        self.old_model_keys.remove((rem_app_label, rem_model_name))
                        self.old_model_keys.append((app_label, model_name))
                        break
