Toms Code
Toms Code

Reputation: 1689

Add new line (and bullet points) in Django forms label?

I have a form:

class FormFood(forms.Form):
    CHOICES = [ (1,'Yes'), (2, 'No')]
    response = forms.ChoiceField(widget=forms.RadioSelect,
              label="Would you like some pasta, bread or rice?", choices=CHOICES)

It appears like this in my browser:

enter image description here

The problem

I would like 'pasta', 'bread' and 'rice' to appear on different lines with bullet points like this:

Would you like:

What I've tried

Adding \n in the label text and skipping a line using 'enter'. Neither have worked.

Could somebody point me in the right direction as to how best to do this?

Upvotes: 1

Views: 453

Answers (2)

F A
F A

Reputation: 348

Use single quotes than double quotes and write the following-

label='Would you like: <ul><li>pasta</li><li>bread</li><li>rice</li></ul>'

Upvotes: 0

Ali Hassan
Ali Hassan

Reputation: 966

Try this, with closing tag of '<ul>' there will be a continuous spaces if you ever need to add more labels. but with close '</ul>' tag all other label with different option will aligned.

label = 'Would you like: <ul><li>pasta</li><li>bread</li><li>rice</li></ul>'

Upvotes: 1

Related Questions