python - How to add help_text to display as input value? -


I would like to get help_text declared in my form class to render inside the HTML form element Instead of the default of DJGengo, which displays it as a separate element, specially, help_text for the Tedarea field will need to go between the opening and closing HTML tags and input fields, help_text to value = < / Code> attribute - basically, by changing:

  tex T = forms.CharField (widget = forms.Textarea (attrs = {'class': 'form-control', 'rows': 2}), help_text = "some help text") image = outline (widget = forms. Text input (Ethers = {'class': 'form-control'}), help_text = "more help text")  

In::

  & lt ; Textarea class = "form-control" id = "id_text" name = "text" rows = "2" & gt; Some help text & lt; / Textarea & gt; & Lt; Input class = "form-control" id = "id_image" name = "image" value = "more help text" & gt;  

As such, the first block of code does not include help_text anywhere.

One way to do this is to use the template tag to insert everything inline, but it feels like a hack.

  & lt; Textarea class = "form-control" id = "{{form.text.auto_id}}" name = "{{form.text.html_name}}" line = "2" & gt; {{Form.text.help_text}} & lt; / Textarea & gt; & Lt; Input class = "form-control" id = "{{form.image.auto_id}}" name = "{{form.image.html_name}}" value = "{{form.image.help_text}}" gt;  

Do I think there will be a better way?

Instead of using help_text , placeholder < Use the / code> attribute.

  text = forms.CharField (widget = forms.TextInput (attrs = {'placeholder': 'some help text'}))  
< / Html>

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -