本文整理汇总了Python中django.contrib.admin.ModelAdmin.formfield_for_dbfield方法的典型用法代码示例。如果您正苦于以下问题:Python ModelAdmin.formfield_for_dbfield方法的具体用法?Python ModelAdmin.formfield_for_dbfield怎么用?Python ModelAdmin.formfield_for_dbfield使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.admin.ModelAdmin
的用法示例。
在下文中一共展示了ModelAdmin.formfield_for_dbfield方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: formfield_for_dbfield
# 需要导入模块: from django.contrib.admin import ModelAdmin [as 别名]
# 或者: from django.contrib.admin.ModelAdmin import formfield_for_dbfield [as 别名]
def formfield_for_dbfield(self, db_field, **kwargs):
ret = DjangoModelAdmin.formfield_for_dbfield(self, db_field, **kwargs)
if ret and isinstance(ret.widget, widgets.RelatedFieldWidgetWrapper):
ret.widget.__class__ = IRelatedFieldWidgetWrapper
return ret
示例2: formfield_for_dbfield
# 需要导入模块: from django.contrib.admin import ModelAdmin [as 别名]
# 或者: from django.contrib.admin.ModelAdmin import formfield_for_dbfield [as 别名]
def formfield_for_dbfield(self, db_field, **kwargs):
if isinstance(db_field, models.FileField):
return self.formfield_for_file_field(db_field, kwargs.pop("request", None), **kwargs)
return ModelAdmin.formfield_for_dbfield(self, db_field, **kwargs)