Django ModelForm Example


Example

Create a ModelForm from an existing Model class, by subclassing ModelForm:

from django import forms

class OrderForm(forms.ModelForm):
    class Meta:
        model = Order
        fields = ['item', 'order_date', 'customer', 'status']