[Django]-Django: best way to define a form to insert long texts?

4👍

Your code should remain that way:

selected_services = forms.CharField(label="Selected_services *",
                                widget=forms.Textarea())

Defining the TextArea widget becomes a TextField and the max_length attribute is not required

2👍

Only models.CharField requires max_length. You can remove it from your forms.CharField.

Apart from that your current code looks fine. The TextArea is the right widget to use.

1👍

max_length property doesn’t appear to have an upper limit.

I’ve checked the source code and this forms documentation

So you might wanna try using sys.maxint (python 2) or sys.maxsize (python 3) instead of arbitrary number.

👤Adelin

Leave a comment