resize modelform fields on template

69 views
Skip to first unread message

mapapage

unread,
Sep 3, 2012, 6:09:22 AM9/3/12
to django...@googlegroups.com
Hi all!
I'd like to know if there's a way to resize my modelform fields on the template. They're being rendered too big for the text input.
I tried this :
  name = forms.CharField(
               widget=forms.TextInput(attrs={'size':'40'}))
but it didn't work.
I also changed the width in css but unsuccessfully.
Do you have any solution to suggest?
Thx!

Mike Dewhirst

unread,
Mar 15, 2013, 1:25:59 AM3/15/13
to django...@googlegroups.com
On 15/03/2013 11:05am, cabrazil wrote:
> Hi,
>
> I have the same problem. Have you recieved any help?
> Thanks.
>
> Em segunda-feira, 3 de setembro de 2012 07h09min22s UTC-3, mapapage
> escreveu:
>
> Hi all!
> I'd like to know if there's a way to resize my modelform fields on
> the template. They're being rendered too big for the text input.
> I tried this :
>
> name = forms.CharField(
> widget=forms.TextInput(attrs={'size':'40'}))
>
> but it didn't work.
>

Try this in your css ...

.field-<fieldname> .vLargeTextField {
width: 40px !important;
height: 40px;
}




> I also changed the width in css but unsuccessfully.
>
> Do you have any solution to suggest?
>
> Thx!
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Mike Dewhirst

unread,
Mar 15, 2013, 1:37:22 AM3/15/13
to django...@googlegroups.com
On 15/03/2013 4:25pm, Mike Dewhirst wrote:
> On 15/03/2013 11:05am, cabrazil wrote:
>> Hi,
>>
>> I have the same problem. Have you recieved any help?
>> Thanks.
>>
>> Em segunda-feira, 3 de setembro de 2012 07h09min22s UTC-3, mapapage
>> escreveu:
>>
>> Hi all!
>> I'd like to know if there's a way to resize my modelform fields on
>> the template. They're being rendered too big for the text input.
>> I tried this :
>>
>> name = forms.CharField(
>> widget=forms.TextInput(attrs={'size':'40'}))
>>
>> but it didn't work.
>>
>
> Try this in your css ...
>
> .field-<fieldname> .vLargeTextField {
> width: 40px !important;
> height: 40px;
> }

or for all TextField ...

.vLargeTextField {
width: 40em !important;
height: 40px;
}

or all ordinary CharField ...

.vTextField {
width: 30em !important;
height: 40px;
}

I haven't played with the widgets but the docs will possibly tell you
the attributes are rows and cols rather than size.

Mike
Reply all
Reply to author
Forward
0 new messages