Pergunta

I intend to accept the values for the fields in my form from the user. However, I wish to have a common heading in the first row on the page for all of the rows (since the user will be adding multiple rows). I need help with telling django to not show the field name to the user and only show the textarea for entering the value.

How do I disable the display of the field name that is being shown in the form?

Foi útil?

Solução 2

In my models.py, I added the verbose_name field and set it to blank.

field1 = models.CharField(max_length=512,verbose_name="",)

This ensures that the field name:field1 is not shown when the form is displayed.

Outras dicas

Use this pattern:

<table>
   <thead>
      <tr>
         {% for field in form %}
            <th>{{ field.label }}</th>
         {% endfor %}
      </tr>
   </thead>
   <tbody>
      <tr>
      {% for field in form %}
          <td>{{ field.widget }}</td>
      {% endfor %}
      </tr>
   </tbody>
</table>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top