Django’s newforms

I was working through a file upload form using Django’s newforms. I wanted a file upload field with a custom size attribute similar to:

<input id=”id_file” type=”file” name=”file” size=”45″ />

The problem was trying to figure out how to specify the “size” attribute. Finally after wasting enough time I googled and found Ben’s blog posting. It seems Ben also was frustrated in trying to figure out how this worked. This is very new stuff (newforms), but I hope the Django authors get the documentation fleshed out a bit more sooner than later. BTW…the documenation page on newforms is here.

Here is a sample of my file input form field with a size specified:

file = forms.Field(label=”Resume File”, required=True, widget=forms.FileInput({‘size’: 45}) )

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s