Django filefield limitation: 100 chars max

Tags: django

A colleague just got an error 500 when uploading a file. Two previous uploads were ok, so we started to suspect the quite long filename of that third, failing, file.

I looked in the log file and saw a field length error:

DatabaseError: value too long for type character varying(100)

I looked at Django’s excellent online documentation for the FileField and saw that, by default it turns into a varchar(100) database column.

This is the first time I’ve personally seen an error come out of it, but at least it is something to keep in mind. You can change the default by passing a max_length attribute, so if you need it you can change it.

Photo & Video Sharing by SmugMug
 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):