How to create a Textarea in a Django form

- Andrés Cruz

En español

In this post, we will see how to create a textarea in a form in Django and with this, have a larger textarea to be able to write instead of a text type input in which we can only write texts on a single line , widely used to create comment albums or to write a description and like every field in HTML, it is perfectly customizable at the style level.

Textareas are common for things like entering comments or other extensive information.

 

How can we create a textarea in Django?

The following code below can be used to create a textarea in a Django form:

comment= forms.CharField(widget=forms.Textarea)

We can also customize the attributes, such as in this case the rows and columns:

comment= forms.CharField(widget=forms.Textarea(attrs={"rows":8, "cols":10})

In this example, we create a textarea with 8 rows and 10 columns.

Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.

!Courses from!

10$

On Udemy

There are 2d 16:25!


Udemy

!Courses from!

4$

In Academy

View courses

!Books from!

1$

See the books
¡Become an affiliate on Gumroad!