我在表单中有这些字段:
city = forms.ModelChoiceField(label="city", queryset=MyCity.objects.all())
district = forms.ModelChoiceField(label="district", queryset=MyDistrict.objects.all())
area = forms.ModelChoiceField(label="area", queryset=MyArea.objects.all())
district来自点击city,area来自点击area。使用queryset=MyDistrict.objects.all()
和queryset=MyArea.objects.all()
形式会很重。如何使查询集默认为空?
最佳答案
关于django - 默认情况下在 Django 表单字段中创建空查询集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11243559/