小编Joa*_*one的帖子

如何在 django 3 中使用 RelatedFieldWidgetWrapper

我应该在 rel 和 admin 站点中放什么?这是我表单中的字段:

tutor_temporal = forms.ModelChoiceField(
    queryset=Tutor_temporal.objects.all(),
    label='Tutor No Registrado', 
    required=False,
    widget=RelatedFieldWidgetWrapper(
        widget=forms.Select(attrs={'class': 'input is-small is-rounded'}),
        rel=Tutor_temporal._meta.get_field('id').rel,
        admin_site= admin_site
    )
)
Run Code Online (Sandbox Code Playgroud)

问题是,当我尝试这样做时,会抛出这个 AttributeError: 'AutoField' object has no attribute 'rel',因为显然已被弃用。

django django-forms

3
推荐指数
1
解决办法
534
查看次数

标签 统计

django ×1

django-forms ×1