[patch] FileField does not allow modifications on Windows
|Reported by:||radek||Owned by:||adrian|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
When you have FileField (or ImageField) and use Django on Windows, 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.
The issue is in
\django\trunk\django\db\models\fields\init.py on line 579
You can see missing Drive name.
Patch is here:
@@ -576,7 +576,7 @@ # If the raw path is passed in, validate it's under the MEDIA_ROOT. def isWithinMediaRoot(field_data, all_data): f = os.path.abspath(os.path.join(settings.MEDIA_ROOT, field_data)) - if not f.startswith(os.path.normpath(settings.MEDIA_ROOT)): + if not f.startswith(os.path.abspath(os.path.normpath(settings.MEDIA_ROOT))): raise validators.ValidationError, _("Enter a valid filename.") field_list.validator_list.append(isWithinMediaRoot) return field_list
Pitty I spent a whole day, before I found it.
Change History (8)
comment:1 Changed 10 years ago by SmileyChris
- Summary changed from FileField does not allow modifications on Windows to [patch] FileField does not allow modifications on Windows
comment:2 Changed 10 years ago by adrian
- priority changed from highest to normal
- Severity changed from blocker to normal
comment:3 Changed 10 years ago by anonymous
- Resolution set to fixed
- Status changed from new to closed
comment:6 Changed 8 years ago by justin.driscoll@…
- Patch needs improvement set
- Resolution fixed deleted
- Status changed from closed to reopened