-
使用
檢索表單域的初始數據。如果存在,它將從BoundField.initial檢索數據,否則嘗試Form.initial。評估可調用值。有關更多示例,請參閱初始表單值。Field.initial緩存其返回值,這在處理返回值可以更改的可調用對象時尤其有用(例如BoundField.initialdatetime.now或uuid.uuid4):>>> from datetime import datetime >>> class DatedCommentForm(CommentForm): ... created = forms.DateTimeField(initial=datetime.now) >>> f = DatedCommentForm() >>> f['created'].initial datetime.datetime(2021, 7, 27, 9, 5, 54) >>> f['created'].initial datetime.datetime(2021, 7, 27, 9, 5, 54)建議使用
而不是BoundField.initial。get_initial_for_field()
本文介紹 django.forms.BoundField.initial 的用法。
聲明
BoundField.initial
相關用法
- Python Django BoundField.id_for_label用法及代碼示例
- Python Django BoundField.label_tag用法及代碼示例
- Python Django BoundField.value用法及代碼示例
- Python Django BoundField.css_classes用法及代碼示例
- Python Django BoundField.errors用法及代碼示例
- Python Django BoundField.data用法及代碼示例
- Python Django BoundField.name用法及代碼示例
- Python Django BoundField.widget_type用法及代碼示例
- Python Django BoolOr用法及代碼示例
- Python PIL BoxBlur()用法及代碼示例
- Python Django BoolAnd用法及代碼示例
- Python Bytes轉Int用法及代碼示例
- Python Bytes轉String用法及代碼示例
- Python Django BaseCommand.style用法及代碼示例
- Python Django BaseFormSet.get_ordering_widget用法及代碼示例
- Python Binary轉Hexadecimal用法及代碼示例
- Python BaseException.with_traceback用法及代碼示例
- Python Django BaseFormSet.ordering_widget用法及代碼示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代碼示例
- Python torch.distributed.rpc.rpc_async用法及代碼示例
- Python torch.nn.InstanceNorm3d用法及代碼示例
- Python sklearn.cluster.MiniBatchKMeans用法及代碼示例
- Python pandas.arrays.IntervalArray.is_empty用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python numpy.less()用法及代碼示例
注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.forms.BoundField.initial。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
