28

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.

4

1 回答 1

32

今天我自己也有这个问题。为了完整起见,这里是当前存在的文档:

https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelforms-overriding-default-fields

摘自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)

从该列表中,我搜索了文档页面上的每个选项以找到我需要的内容。希望对某人有所帮助。

于 2014-02-12T21:36:44.543 回答