Opened 10 years ago

Closed 8 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
Component: Validators Version:
Severity: normal Keywords: david.ascher@gmail.com
Cc: django@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

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 self.photo
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 10 years ago by David Ascher <david.ascher@…>

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

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

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

  • Keywords david.ascher@gmail.com added

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

  • Component changed from Admin interface to Validators

This one bit me for a few hours today, too. The solution for me was to set MEDIA_ROOT in my settings.py, 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 9 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 9 years ago by Stefano J. Attardi <django@…>

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

comment:6 Changed 8 years ago by SmileyChris

  • Resolution set to duplicate
  • Status changed from new to closed

#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