在Django中,如何基于从下拉列表中选择的值填充数据。 这些字段也是从另一个模型继承的。 例如: 类DeviceInfo有4个字段,类似于继承到类链接
如何设置视图,以便通过下拉选择name
它将预填充位置、类型,然后用户可以填写rest字段
型号:
class DeviceInfo(models.Model):
name = models.CharField(max_length=20, default='')
location = models.GenericIPAddressField(protocol='IPv4', default='0.0.0.0')
type = models.ForeignKey(Types, on_delete=models.SET_NULL, null=True)
class Links(DeviceInfo, models.Model):
{other fields}
形式
class DeviceInfo_form(forms.ModelForm):
class Meta:
model = DeviceInfo
fields = '__all__'
field_classes = {
'json_field': JSONFormField,
}
感谢您抽出时间回答
目前没有回答
相关问题 更多 >
编程相关推荐