1

How can I prevent this from happening

I am talking about this

Willem Van Onsem
  • 397,926
  • 29
  • 362
  • 485
dsal3389
  • 459
  • 5
  • 21

1 Answers1

0

A Django TextField is rendered as a HTML textarea.

Looking at this question, you could use style="resize: none;".

If you would like to add that in your views/form (and not in the templates), you could try something like:

class MyModelForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['my_field_name'].widget.attrs['style'] = 'resize: none;'

or if you have a form instance

form.fields['my_field_name'].widget.attrs['style'] = 'resize: none;'
Ralf
  • 14,947
  • 4
  • 39
  • 61