Opened 9 years ago

Closed 8 years ago

#3018 closed defect (worksforme)

[patch] FileField does not allow modifications with upload_to set

Reported by: ido Owned by: adrian
Component: contrib.admin Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When you have FileField with the upload_to option; second time uploaded filename is always considered invalid.
Ie. you can create one instance, but you can't go back and edit this one and save. You always get:

Enter a valid filename.

This is very similar to ticket #2923

The issue is in: djang/db/models/fields/init__.py:def isWithinMediaRoot

this validator check explicitly if the uploaded file is in settings.MEDIA_ROOT
while part of the point of upload_to is that you can specify another directory.

i changed "settings.MEDIA_ROOT" to "self.upload_to or settings.MEDIA_ROOT"
to ensure that if upload_to is set, that location is used.

Attachments (1)

patch-db-models-fields-filefield.patch (850 bytes) - added by ido 9 years ago.
patch for ticket #3018

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by ido

patch for ticket #3018

comment:1 Changed 9 years ago by anonymous

  • milestone set to Version 1.0
  • Version set to SVN

comment:2 Changed 9 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

comment:3 Changed 8 years ago by anonymous

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

Works for me.

Ticket #2923 already fixed the problem.

Your patch isn't needed because the saved path in the filefield already includes the upload_to part.

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