Django的ModelForm - Meta选项列表在哪里? [英] Django's ModelForm - where is the list of Meta options?
问题描述
在Django文档中, Meta
的明确列表在哪里 django.forms.models.ModelForm
? (例如, model
, exclude
, fields
, widgets
)我正在寻找相当于模型元选项。
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.
推荐答案
今天有这个问题。为了完整起见,以下是当前存在的文档:
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
而从 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)
从该列表中,我搜索了docs页面上的每个选项,找到我需要的。希望帮助某人。
From that list, I searched for each option on the docs page to find what I needed. Hope that helps someone.
这篇关于Django的ModelForm - Meta选项列表在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!