Django's ModelForm - where is the list of Meta options?

后端 未结 1 1125
南方客
南方客 2020-12-28 14:47

In the Django documentation, where is the definitive list of Meta options for django.forms.models.ModelForm? (e.g., model, excl

相关标签:
1条回答
  • 2020-12-28 15:14

    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(object):
        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)
    

    From that list, I searched for each option on the docs page to find what I needed. Hope that helps someone.

    0 讨论(0)
提交回复
热议问题