Python django.forms.py() Examples
The following are 2
code examples of django.forms.py().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.forms
, or try the search function
.
Example #1
Source File: django inlineformset_factory add remove.py From Some-Examples-of-Simple-Python-Script with GNU Affero General Public License v3.0 | 5 votes |
def __unicode__(self): return self.foto_bukti_pembayaran.name #------------------forms.py-------------------------
Example #2
Source File: base.py From wagtail with BSD 3-Clause "New" or "Revised" License | 4 votes |
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())