On 5/4/07, Pythoni <[EMAIL PROTECTED]> wrote:
>
> One of the field in my model is defined
> Description=meta.TextField()
>
> When I use
> {{form.Description}}
> in my input form( template)
> the field is not as large as I would need.
> When I check HTML I can see
>
>  <textarea id="id_Description" class="vLargeTextField required"
> name="Description" rows="10" cols="40"></textarea>
>
> But I would need at least rows="20" cols="70".
> Is there a way how to change the size from Django directly and not by
> editing HTML code?

Using newforms, yes:

Pass in an 'attrs' argument to the Textarea widget. e.g.,

class MyForm(forms.Form):
    text = fields.TextField(widget=widgets.Textarea(attrs={'cols':'70',
'rows':'20'}))

This defines a text field that will use a Textarea widget to render;
by default, Textarea uses 1 40x10 area, but this can be overridden.

if you want to get really fancy, you can define your own subclass of
Textarea that hard codes your preferred sizes, and then request that
the TextField you the new widget :

class MyTextarea(widgets.Textarea):
    def __init__(self, attrs={}):
        attrs.update({'cols':'70', 'rows':'20'})
        super(MyTextarea, self).__init__(attrs)

class MyForm(forms.Form):
    text = fields.TextField(widget=widgets.MyTextarea)

(Note - I haven't run this code so it might have a syntax error or
two, but it should be enough to give you an idea and get you on the
way).

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to