# Feature request: wigets attribute for ModelFormMixin class ### Status quo
The `ModelFormMixin` class currently implements the `fields` attribute by it self and pass it to the `modelform_factory`: ```python class ModelFormMixin(FormMixin, SingleObjectMixin): """Provide a way to show and handle a ModelForm in a request.""" fields = None def get_form_class(self): """Return the form class to use in this view.""" if self.fields is not None and self.form_class: raise ImproperlyConfigured( "Specifying both 'fields' and 'form_class' is not permitted." ) if self.form_class: return self.form_class else: ... return model_forms.modelform_factory(model, fields=self.fields) ``` On generic `CreateView` for example the field can be configured like: ```python class MonitoringRunNewView(CreateView): model = MonitoringRun fields = ('metadatas', ) ... ``` Same can be done in `UpdateView` and so on. ### Enhancement Provide the possibility to declare widgets for the configured fields also like: ```python class ModelFormMixin(FormMixin, SingleObjectMixin): """Provide a way to show and handle a ModelForm in a request.""" fields = None widgets = None def get_form_class(self): """Return the form class to use in this view.""" if self.fields is not None and self.form_class: raise ImproperlyConfigured( "Specifying both 'fields' and 'form_class' is not permitted." ) if self.form_class: return self.form_class else: ... return model_forms.modelform_factory(model, fields=self.fields, widgets=self.widgets) ``` ```python class MonitoringRunNewView(CreateView): model = MonitoringRun fields = ('metadatas', ) widgets = {'metadatas': forms.HiddenInput()} ... ``` Configuring of `labels`, `help_texts` and `error_messages` could also be helpfull. For that we also simply need to pass the attributes as in the example above described. -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/25e0e4a1-d3f5-4f18-945f-304ea140e22an%40googlegroups.com.