ModelForm 示例
通过子类化 ModelForm
从现有的 Model 类创建 ModelForm:
from django import forms
class OrderForm(forms.ModelForm):
class Meta:
model = Order
fields = ['item', 'order_date', 'customer', 'status']
通过子类化 ModelForm
从现有的 Model 类创建 ModelForm:
from django import forms
class OrderForm(forms.ModelForm):
class Meta:
model = Order
fields = ['item', 'order_date', 'customer', 'status']