-
包含要在呈現的小部件上設置的 HTML 屬性的字典。
>>> from django import forms >>> name = forms.TextInput(attrs={'size': 10, 'title': 'Your name'}) >>> name.render('name', 'A name') '<input title="Your name" type="text" name="name" value="A name" size="10">'
如果您為屬性分配
True
或False
的值,它將被呈現為 HTML5 布爾屬性:>>> name = forms.TextInput(attrs={'required': True}) >>> name.render('name', 'A name') '<input name="name" type="text" value="A name" required>' >>> >>> name = forms.TextInput(attrs={'required': False}) >>> name.render('name', 'A name') '<input name="name" type="text" value="A name">'
本文介紹 django.forms.Widget.attrs
的用法。
聲明
attrs
相關用法
- Python Wand negate()用法及代碼示例
- Python Wand wavelet_denoise()用法及代碼示例
- Python Wand local_contrast()用法及代碼示例
- Python Wand sample()用法及代碼示例
- Python Wand deskew()用法及代碼示例
- Python Wand color()用法及代碼示例
- Python Wand implode()用法及代碼示例
- Python Wand adaptive_blur()用法及代碼示例
- Python Wand unsharp_mask()用法及代碼示例
- Python Wand gaussian_blur()用法及代碼示例
- Python Wand polaroid()用法及代碼示例
- Python Django WKBWriter.write_hex用法及代碼示例
- Python Wand adaptive_sharpen()用法及代碼示例
- Python Wand posterize()用法及代碼示例
- Python Wand path_move()用法及代碼示例
- Python Wand transform()用法及代碼示例
- Python Wand shave()用法及代碼示例
- Python Django WKTWriter.trim用法及代碼示例
- Python Wand function()用法及代碼示例
- Python Wand level()用法及代碼示例
- Python Wand swirl()用法及代碼示例
- Python Wand canny()用法及代碼示例
- Python Django WKBReader用法及代碼示例
- Python Wand rectangle()用法及代碼示例
- Python Wand composite()用法及代碼示例
注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.forms.Widget.attrs。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。