def formfield_for_dbfield(self, db_field, **kwargs):
        formfield = super(EnhancedAdminMixin, self).formfield_for_dbfield(db_field, **kwargs)
        if (formfield and db_field.name not in self.enhance_exclude and
                isinstance(formfield.widget, admin.widgets.RelatedFieldWidgetWrapper)):
            request = kwargs.pop('request', None)
            related_modeladmin = self.admin_site._registry.get(db_field.rel.to)
            if related_modeladmin:
                can_change_related = related_modeladmin.has_change_permission(request)
                can_delete_related = related_modeladmin.has_delete_permission(request)
                widget = self.related_widget_wrapper.wrap(formfield.widget,
                                                          can_change_related,
                                                          can_delete_related)
                formfield.widget = widget
        return formfield
dataset/ETHPy150Open charettes/django-admin-enhancer/admin_enhancer/admin.py/EnhancedAdminMixin.formfield_for_dbfield/original