本文整理汇总了Python中django.forms.Form.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Form.__init__方法的具体用法?Python Form.__init__怎么用?Python Form.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms.Form
的用法示例。
在下文中一共展示了Form.__init__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from django.forms import Form [as 别名]
# 或者: from django.forms.Form import __init__ [as 别名]
def __init__(self, formdata, request, *args, **kwargs):
Form.__init__(self, formdata, *args, **kwargs)
self.fields["entries_selected"] = ModelMultipleChoiceField(
required=False, queryset=PomEntry.objects.filter(author=request.user)
)
self.fields["categories_selected"] = ModelMultipleChoiceField(
required=False, queryset=PomCategory.objects.filter(pomentry__author=request.user).distinct()
)
self.fields["users_selected"] = ModelMultipleChoiceField(
queryset=User.objects.exclude(username=request.user.username)
)
示例2: __init__
# 需要导入模块: from django.forms import Form [as 别名]
# 或者: from django.forms.Form import __init__ [as 别名]
def __init__(self, user, *args, **kwargs):
Form.__init__(self, *args, **kwargs)
assocs = UserAssociation.objects.filter(user=user)
if assocs.count() == 0:
raise UserAssociation.DoesNotExist()
vals = assocs.order_by('openid_url').values_list('openid_url', flat=True)
self.fields['openid_url_to_delete'].choices = ((val, val) for val in vals)
self._user = user
self._assoc = None