tags:

views:

609

answers:

2

I'm on Mac Leopard. Trying to get django admin file uploads, or really image uploads to work. In my app's models.py I set the field to:

image = models.FileField(upload_to='images', max_length=500)

(started w/ ImageField, but thought if a file doesn't work, then the image for sure won't work)

It says the upload happened. Gives me a positive result. Saves the path to my database. But looking for the file, well, it isn't there.

Since there's no error message, it's hard to debug. Tried various permissions, but nothing is working.

Any ideas?

+4  A: 

Is your MEDIA_ROOT set correctly? http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield

Ellie P.
Yes. I'm using MEDIA_ROOT/js to serve .js files w/o a problem. (Images point to MEDIA_ROOT/images of course.)
joedevon
Actually, that made me take another look! Turns out I had a symlink so just in case I double checked to make sure I was pointing to the real path and I wasn't. After making the switch, it works! As does ImageField, only thing left to fix is "object has no attribute 'image_width'"...for some reason that isn't being populated...thumbnail = models.ImageField(upload_to='images/thumb', height_field='thumb_height', width_field='thumb_width', max_length=500)
joedevon
Oh man, I should have suggested symlink mistakes, because they have caused me static content problems too numerous to mention. No idea about the image_width problem, sorry.
Ellie P.
Thanks Ellie. BTW, figured out the image_width issue. You need to specify those explicitly in the model even though they are mentioned in the ImageField line. I wish they had examples to go along w/ each option so we know how to implement it correctly.
joedevon
+1  A: 

From the comments it sounds like you found a solution to your issue. For future reference, you may want to check out django-debug-toolbar to help you troubleshoot problems like this (Especially when there's no error, it just doesn't work right!). Code available here: http://github.com/robhudson/django-debug-toolbar/tree/master

John Debs
Yes, the original issue is solved. Seems others had my image_width problem, but it was supposed to be fixed:http://code.djangoproject.com/ticket/10196Re: Toolbar; looks interesting.
joedevon