I am trying to use the height_field and width_field arguments for
ImageField to auto-populate the dimension of images to other fields, but
it doesn't seem to be working.
I've duplicated the usage that's in Django's test suite (which
incidentally is the only mention I can find that you have to pass the
fields as strings rather than passing the fields themselves), and I've
produced the following model for testing this (after it didn't work on
my regular model).
class Test(models.Model):
image =
models.ImageField(upload_to='banners',height_field='image_height',width_field='image_width')
image_width = models.PositiveSmallIntegerField(editable=False)
image_height = models.PositiveSmallIntegerField(editable=False)
But when I try to upload the Image I get the following exception:
Exception Type: IntegrityError at /admin/banners/test/add/
Exception Value: (1048, "Column 'image_width' cannot be null")
If I allow the image_width and image_height fields to be Null, the image
itself gets uploaded fine but the dimension fields don't get populated.
I'm on Mac OSX 10.5 and I'm using the very latest revision of trunk. PIL
is installed and working.
Regards,
Andrew Ingram
So the next thing is to narrow down which commit. You know a good commit
and you know a bad one. Now pick something halfway in between and try
that. Continue with binary searching. It won't take many repetitions to
get to the precise commit.
Regards,
Malcolm
"Fixed #10044: You can now assign directly to file fields
(`instance.filefield = somefile`)."
http://code.djangoproject.com/ticket/10044
It's late now, but I'll update the ticket tommorrow if nobody else has
by then.
Regards,
Andrew Ingram