... の異なる入力タイプを使用するために、 'type' 属性を指定することも可能です。これを行うには、ウィジェットを作成する際に Widget.attrs 引数を使用します。 class CommentForm ( forms . Form ): name = forms . CharField ( widget = forms . TextInput ( attrs = { " ... class" : "special" })) url = forms . URLField () comment = forms . CharField ( widget = forms . TextInput ( attrs = { "size" : "40" })) フォーム定義内でウィジェットを変更することもできます: class CommentForm ( forms . Form ): name = for ... ms . CharField () url = forms . URLField () comment = forms . CharField () name . widget . attrs . update ({ "class" : "special" }) comment . widget . attrs . update ( size = "40" ) あるいは、フォームに直接フィールドが宣 ... ... "subject" ] . legend_tag () <legend class="required" for="id_subject">Subject:</legend> >>> f [ "subject" ] . label_tag ( attrs = { "class" : "foo" }) <label for="id_subject" class="foo required">Subject:</label> >>> f [ "subject" ] . legend_tag ( at ... ソース] フィールドをそのヘルプテキストやエラーメッセージと関連付けるための aria-describedby 参照を返します。ただし、 Widget.attrs に aria-describedby がすでに設定されている場合は、ユーザー定義の属性を保持するために None を返します。 BoundField. auto_id ... ォルトでは、これはフィールドの名前に id_ を前につけたものになります(上の例では " id_my_field ")。フィールドのウィジェットの attrs を設定することで、IDを変更できます。例えば、以下のようにフィールドを宣言します: my_field = forms . CharField ( widget = fo ... ... n particular, when the login page is accessed directly) ( #28229 ). Prevented attribute values in the django/forms/widgets/attrs.html template from being localized so that numeric attributes (e.g. max and min ) of NumberInput work correctly ( #28303 ) ... ... 削除されました。 IPython 1.0 未満へのサポートが shell コマンドから削除されました。 The signature of private API Widget.build_attrs() changed from extra_attrs=None, **kwargs to base_attrs, extra_attrs=None . File-like objects (e.g., StringIO and BytesIO ... ... o use template-based widget rendering ( #28040 ). Fixed crash in BaseGeometryWidget.get_context() when overriding existing attrs ( #28105 ). Prevented AddIndex and RemoveIndex from mutating model state ( #28043 ). Prevented migrations from dropping da ... ... nstance . some_attribute , new_instance . some_attribute ) データベースのカラム定義に影響しないフィールド属性 Field.non_db_attrs をオーバーライドすることで、カラム定義に影響しないフィールドの属性をカスタマイズできます。これはモデルのマイグレーションの ... 間に使われ、no-opの AlterField 操作を検出します。 例えば: class CommaSepField ( models . Field ): @property def non_db_attrs ( self ): return super () . non_db_attrs + ( "separator" ,) カスタムフィールドのベースクラスを変更する カスタムフィールドの ... ... ードジェネレーターの実装を次のように始めることができます: class iTunesFeed ( Rss201rev2Feed ): def root_attributes ( self ): attrs = super () . root_attributes () attrs [ "xmlns:itunes" ] = "http://www.itunes.com/dtds/podcast-1.0.dtd" return attrs def a ... ... forms . CharField ( ... max_length = 255 , ... help_text = "e.g., user@example.com" , ... widget = forms . TextInput ( ... attrs = { "aria-describedby" : "custom-description id_username_helptext" }, ... ), ... ) ... >>> f = UserForm () >>> print ( f [ ... s ToppingSelect ( forms . Select ): def create_option ( self , name , value , label , selected , index , subindex = None , attrs = None ): option = super () . create_option ( name , value , label , selected , index , subindex , attrs ) if value : opti ... on [ "attrs" ][ "data-price" ] = value . instance . price return option class PizzaForm ( forms . ModelForm ): class Meta : model = Pi ... ... ikely unintended, since SQL NULL cannot match any value. Fixed a regression in Django 6.1 where legend_tag() with a custom attrs could add the required_css_class more than once ( #37463 ). Added compatibility for oracledb 26.0.0+ ( #37411 ). Fixed a c ... ... jango.contrib.gis import forms class MyGeoForm ( forms . Form ): point = forms . PointField ( widget = forms . OSMWidget ( attrs = { "display_raw" : True })) Widget クラス BaseGeometryWidget class BaseGeometryWidget [ソース] これは、サブクラスが必要と ... 2026年10月08日