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']