使用模型表单工厂来简化

    1. #views.py
    2. from django.forms import modelform_factory
    3. def show(request):
    4. author_form = modelform_factory(Author, exclude=['id'])
    5. return render(request, 'show_author.html', {'author_form':author_form})

    支持的属性与ModelForm元数据中支持的数据基本一致,例如widgets, help_texts, labels等