How to avoid repeating field list in ModelForm and CreateView class?
问题 I'm using django.forms.ModelForm and django.views.generic.CreateView to create a creation view for my model. I find that I end up with this code: forms.py: class ScenarioForm(forms.ModelForm): class Meta: model = Scenario fields = ['scenario_name', 'description', 'scenario_file', 'preview'] views.py: class ScenarioUpload(generic.CreateView): model = Scenario fields = ['scenario_name', 'description', 'scenario_file', 'preview'] form_class = ScenarioForm It seems like really bad repetition. Is