Jinesh
Jinesh

Reputation: 2575

give line break in django form.init data

I have a django form as given below.

class SampleForm(forms.Form):
    message = forms.CharField(widget=forms.Textarea())

When I create a form object i want to initialize the 'message' textarea with a long paragraph. But I need to split the text at certain positions. So I tried to put '\n' and then '< br />'. Both seems not working!. How can this be achieved in django form?. welcome for any suggestion.

Edit: this is the form initialization code:

 def sample_view(request):
     initial = {'message':'''Hello,\nThis is how my message \n look like. '''}
     form = SampleForm(initial=initial)

Upvotes: 3

Views: 1399

Answers (1)

Jinesh
Jinesh

Reputation: 2575

'\n' will do the trick here...

Upvotes: 3

Related Questions