1

How can I prevent this from happening

I am talking about this

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
dsal3389
  • 658
  • 1
  • 7
  • 26

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
  • 16,086
  • 4
  • 44
  • 68