本文整理匯總了Python中myproject.myapp.models.User方法的典型用法代碼示例。如果您正苦於以下問題:Python models.User方法的具體用法?Python models.User怎麽用?Python models.User使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類myproject.myapp.models
的用法示例。
在下文中一共展示了models.User方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: model_form
# 需要導入模塊: from myproject.myapp import models [as 別名]
# 或者: from myproject.myapp.models import User [as 別名]
def model_form(model, base_class=Form, only=None, exclude=None, field_args=None, converter=None):
"""
Create a wtforms Form for a given Django model class::
from wtforms.ext.django.orm import model_form
from myproject.myapp.models import User
UserForm = model_form(User)
:param model:
A Django ORM model class
:param base_class:
Base form class to extend from. Must be a ``wtforms.Form`` subclass.
:param only:
An optional iterable with the property names that should be included in
the form. Only these properties will have fields.
:param exclude:
An optional iterable with the property names that should be excluded
from the form. All other properties will have fields.
:param field_args:
An optional dictionary of field names mapping to keyword arguments used
to construct each field object.
:param converter:
A converter to generate the fields based on the model properties. If
not set, ``ModelConverter`` is used.
"""
field_dict = model_fields(model, only, exclude, field_args, converter)
return type(model._meta.object_name + 'Form', (base_class, ), field_dict)