开发者

Django Forms (Displaying labels)

I have a problem as I ant to have radio buttons list like this:

1)

 How would you rate the cont开发者_如何转开发ent of this site?
 Poor o1 o2 o3 o4 o5 Excellent

But is any possibility to do it in django forms? As now I have:

 How would you rate the content of this site?

 o o1
 o o2
 o o3
 o o4
 o o5

:/

2)

And I have another question like this. Can I do like this?

 Label:
 TextArea here

as I have

 Label: textArea here :/

3)

Is any possibility to put labels into this django forms without creating any field? I mean e.x.: Section1:(label)

 Name: texbox
 Phone: textbox

 Section2:

 hobby: textbox 

etc? I was looking for a good documentation but I couldn't find what I need I mean there weren't to much details :/ Thanks!


Yes - when you use your form in your template, you can interact with the fields individually by accessing form.fieldname - like so:

<p>How would you rate the content of this site?</p>
Poor
{{ form.rating }}
Excellent

If you want to position a form field's label and field differently, you can do that too:

{{ form.fieldname.label }}: {{ form.fieldname }}

And when it comes to displaying labels without a form there, you should be able to just add them to your markup yourself - you don't need Django for that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜