如何在Django管理员中进行设置,以便在单击Forms.IntegerField为空白以返回验证错误时单击保存。当前,如果您保存模型,它将仍然接受交易。
有什么建议吗?
forms.py`
class CarInlineForm(forms.ModelForm):
car_type = forms.CharField(disabled=True)
car_qty = forms.IntegerField(min_value=1)
class Meta:
model = Car
exclude = ['created']
admin.py
class CarInline(admin.TabularInline):
model = CarOrderItem
extra = 1
max_num = 1
form = CarInlineForm
exclude = [
'created',
]
class CarAdmin(admin.ModelAdmin):
inlines = [CarInline]