本文整理匯總了Python中django.forms.py方法的典型用法代碼示例。如果您正苦於以下問題:Python forms.py方法的具體用法?Python forms.py怎麽用?Python forms.py使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.forms
的用法示例。
在下文中一共展示了forms.py方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __unicode__
# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import py [as 別名]
def __unicode__(self):
return self.foto_bukti_pembayaran.name
#------------------forms.py-------------------------
開發者ID:agusmakmun,項目名稱:Some-Examples-of-Simple-Python-Script,代碼行數:7,代碼來源:django inlineformset_factory add remove.py
示例2: __eq__
# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import py [as 別名]
def __eq__(self, other):
"""
Implement equality on block objects so that two blocks with matching definitions are considered
equal. (Block objects are intended to be immutable with the exception of set_name(), so here
'matching definitions' means that both the 'name' property and the constructor args/kwargs - as
captured in _constructor_args - are equal on both blocks.)
This was originally necessary as a workaround for https://code.djangoproject.com/ticket/24340
in Django <1.9; the deep_deconstruct function used to detect changes for migrations did not
recurse into the block lists, and left them as Block instances. This __eq__ method therefore
came into play when identifying changes within migrations.
As of Django >=1.9, this *probably* isn't required any more. However, it may be useful in
future as a way of identifying blocks that can be re-used within StreamField definitions
(https://github.com/wagtail/wagtail/issues/4298#issuecomment-367656028).
"""
if not isinstance(other, Block):
# if the other object isn't a block at all, it clearly isn't equal.
return False
# Note that we do not require the two blocks to be of the exact same class. This is because
# we may wish the following blocks to be considered equal:
#
# class FooBlock(StructBlock):
# first_name = CharBlock()
# surname = CharBlock()
#
# class BarBlock(StructBlock):
# first_name = CharBlock()
# surname = CharBlock()
#
# FooBlock() == BarBlock() == StructBlock([('first_name', CharBlock()), ('surname': CharBlock())])
#
# For this to work, StructBlock will need to ensure that 'deconstruct' returns the same signature
# in all of these cases, including reporting StructBlock as the path:
#
# FooBlock().deconstruct() == (
# 'wagtail.core.blocks.StructBlock',
# [('first_name', CharBlock()), ('surname': CharBlock())],
# {}
# )
#
# This has the bonus side effect that the StructBlock field definition gets frozen into
# the migration, rather than leaving the migration vulnerable to future changes to FooBlock / BarBlock
# in models.py.
return (self.name == other.name) and (self.deconstruct() == other.deconstruct())