In the Django documentation, where is the definitive list of Meta
options for django.forms.models.ModelForm
? (e.g., model
, exclude
, fields
, widgets
) I'm looking for the equivalent of Model Meta Options.
Asked
Active
Viewed 1.9k times
30

Rob Bednark
- 25,981
- 23
- 80
- 125
-
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/ – catherine Mar 12 '13 at 00:51
-
Thanks @catherine. I saw that page, but the ModelForm Meta options are scattered throughout the page, rather than being listed like the Meta options in the Model Meta Options page does. But maybe that's the only documentation for them that exists? – Rob Bednark Mar 12 '13 at 06:49
-
Maybe we can request for that in Django – catherine Mar 12 '13 at 06:57
1 Answers
35
Had this question myself today. For completeness, here is the documentation that currently exists:
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelforms-overriding-default-fields
And an excerpt from django/forms/models.py:
class ModelFormOptions:
def __init__(self, options=None):
self.model = getattr(options, 'model', None)
self.fields = getattr(options, 'fields', None)
self.exclude = getattr(options, 'exclude', None)
self.widgets = getattr(options, 'widgets', None)
self.localized_fields = getattr(options, 'localized_fields', None)
self.labels = getattr(options, 'labels', None)
self.help_texts = getattr(options, 'help_texts', None)
self.error_messages = getattr(options, 'error_messages', None)
self.field_classes = getattr(options, 'field_classes', None)
From that list, I searched for each option on the docs page to find what I needed. Hope that helps someone.

Braiam
- 1
- 11
- 47
- 78

doctaphred
- 2,504
- 1
- 23
- 26
-
1Note that `labels`, `help_texts` and `error_messages` were added in Django 1.6 – Hamish Downer Dec 19 '14 at 12:37
-
-
@SashkoLykhenko you dont "pass" anything to `ModelFormOptions` you define an inner `Meta` class inside your form class and define these "options" as its attributes. then behind the scenes when you create an instance of your form, django creates an instance of your meta class and passes it as "options" to the `ModelFormOptions` class – Kyle Roux Jan 23 '20 at 19:51