Opened 13 years ago

Closed 12 years ago

#934 closed defect (duplicate)

ImageField's cause the admin UI to not allow modifications?

Reported by: David Ascher <david.ascher@…> Owned by: Adrian Holovaty
Component: Validators Version:
Severity: normal Keywords:
Cc: django@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


my model can be boiled down to:

class TestAccount(meta.Model):

photo = meta.ImageField(upload_to="/Users/davida/svk/bankofdad/m/photos", default=)
def repr(self): return
class META:

ordering = ('-photo',)
admin = meta.Admin()

i can create TestAccount instances, but I can't go back and edit one and save. If I do, I always get:

Enter a valid filename.

in the field corresonding to the photo (this even if I browse... to another image).

Change History (6)

comment:1 Changed 13 years ago by David Ascher <david.ascher@…>

Summary: ImageField's are modifiable in the admin UI?ImageField's cause the admin UI to not allow modifications?

(also, should note that I'm on rev 1448

comment:2 Changed 13 years ago by David Ascher <david.ascher@…>

Keywords: added

comment:3 Changed 13 years ago by jim-django@…

Component: Admin interfaceValidators

This one bit me for a few hours today, too. The solution for me was to set MEDIA_ROOT in my, as the file and image field validators check to ensure that the uploaded file will land inside MEDIA_ROOT. This affects all file fields, not just the admin interface.

Short term solution: MEDIA_ROOT and friends need to be documented a lot more comprehensively.

Long term solution: this MEDIA_ROOT stuff is confusing and restrictive. What if I want a different machine to serve banner ad images than the one which serves site graphics? Something more flexible is needed. I'm not the man for the job, though.

comment:4 Changed 12 years ago by Stefano J. Attardi <django@…>

Cc: Stefano J. Attardi <django@…> added

Not only you have to set MEDIA_ROOT, it also has to be an absolute path.

It is actually the only place anywhere in Django that really requires an absolute path. Everything else works fine with relative paths if you are careful about always chdir'ing to the same directory.

comment:5 Changed 12 years ago by Stefano J. Attardi <django@…>

Cc: django@… added; Stefano J. Attardi <django@…> removed

comment:6 Changed 12 years ago by Chris Beaven

Resolution: duplicate
Status: newclosed

#651 covers the issue of not allowing directories names in FileFields, which is the crux of this ticket.

Other issues brought up in the comments should be made as new tickets if they are to get attention.

Note: See TracTickets for help on using tickets.
Back to Top