Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i set the size of rows , columns in textField in Django Models

I have this Model

summary         = models.TextField() 

But I want to have only 4 rows and 15 columns.

Also if I do that do I need to install database again or not.

like image 793
Mirage Avatar asked Jun 30 '11 14:06

Mirage


1 Answers

TextField is a type of field, which when used by a ModelForm by default uses the Textarea widget. Fields deal with backend storage, widgets with front-end editing.

So you need to specify the widget you want to go with your field. You want to create a ModelForm and specify the widget you want to use, per the documentation:

from django import forms  class MyForm(forms.ModelForm):     class Meta:         model = MyModel         widgets = {           'summary': forms.Textarea(attrs={'rows':4, 'cols':15}),         } 
like image 148
Dominic Rodger Avatar answered Oct 12 '22 00:10

Dominic Rodger