'Work out renamed fields.'

def generate_renamed_fields(self):

    self.renamed_fields = {}
    for (app_label, model_name, field_name) in sorted((self.new_field_keys - self.old_field_keys)):
        old_model_name = self.renamed_models.get((app_label, model_name), model_name)
        old_model_state = self.from_state.models[(app_label, old_model_name)]
        field = self.new_apps.get_model(app_label, model_name)._meta.get_field(field_name)
        field_dec = self.deep_deconstruct(field)
        for (rem_app_label, rem_model_name, rem_field_name) in sorted((self.old_field_keys - self.new_field_keys)):
            if ((rem_app_label == app_label) and (rem_model_name == model_name)):
                old_field_dec = self.deep_deconstruct(old_model_state.get_field_by_name(rem_field_name))
                if (field.remote_field and field.remote_field.model and ('to' in old_field_dec[2])):
                    old_rel_to = old_field_dec[2]['to']
                    if (old_rel_to in self.renamed_models_rel):
                        old_field_dec[2]['to'] = self.renamed_models_rel[old_rel_to]
                if (old_field_dec == field_dec):
                    if self.questioner.ask_rename(model_name, rem_field_name, field_name, field):
                        self.add_operation(app_label, operations.RenameField(model_name=model_name, old_name=rem_field_name, new_name=field_name))
                        self.old_field_keys.remove((rem_app_label, rem_model_name, rem_field_name))
                        self.old_field_keys.add((app_label, model_name, field_name))
                        self.renamed_fields[(app_label, model_name, field_name)] = rem_field_name
                        break
