Tuesday, 15 March 2011

Django sub-Form not display label when rendered on template -


After reading, and after working with Django forms for a while, it would seem very standard for me I have to present a Django form in the {{Form.as_p}} template, though my position is slightly different

I have 2 checkboxes with me:

 
Form.form: field_a = forms.BooleanField (initial = false, label = ('FIELD-A')) Field_b = forms.BooleanField (initial = true, label = ('FIELD- B '))

I can add the form object to The more you are, the more it happens: Trying to use the basic 'if' argument, to see if I should show one, or both areas, I know that Most would say, 'Just give them names of two different forms', but I would love to keep them as a form for the purposes of the organization.

Problem

  {% If 'Bold Well'%} & lt; Form action = '' method = 'post' & gt; {{FORM.field_a}} & lt; / Form & gt; {% Endif%}   

This returns only fields , and not field labels (just a checkbox). And when the other stack overflow closes, it should display the entire form including the label, yet it is not.

These methods still work, however:

field in METHOD 1

  {% FORM%} For & lt; Div class = "form" & gt; {{Field.label_tag}} {{Field}} & lt; / Div & gt; {% Endfor%}   

will display both forms with their respective labels and area input (checkboxes)

METHOD 2

  {{FORM.as_p}}   

The traditional way of interpreting the entire form will display both fields and Label, this style is almost identical to Style 1 and Style 1.

Edit Method 3

  {{FORM.field_a.label_tag}} {{ Form.field_a}}   

This label and form will display the field. There is a possible work around, but I see why {{Form.field_a}} does not work on its own.

Therefore ...

< B> Why can not I hand that person's form with my related label? I am not looking for so many jobs to speak, because I want both the fields to be under that one form. Any ideas?

You have tried {code> {{FORM.field_a}} {{FORM.field_a. Label_tag}} ?

No comments:

Post a Comment