Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8466 closed (worksforme)

FileField path url dumpdata/loaddata issue

Reported by: Ian Ward Owned by: nobody
Component: Core (Serialization) Version: dev
Severity: Keywords: FileField path url
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a model that includes a FileField with values such as "/media/uploaded/YEAR/MONTH/NAME" (upload_to='%Y/%m').
I upgraded to Django 1.0 beta svn-8457 and switched from using get_filefiledname_size() to filefiedname.size.
Now, this property triggers a SuspiciousOperation exception: When django.core.files.storage.FileSystemStorage.path is called,
it calls safe_join and decides that the leading slash in the file path puts the file outside of the media root directory.

New instances of this model include a leading slash in the path, so this doesn't seem to be a change
to how the file name is stored.

Change History (4)

comment:1 by Ian Ward, 16 years ago

Component: File uploads/storageSerialization
Keywords: path url added; size removed
Summary: FileField.size triggering SuspiciousOperation exceptionFileField path url dumpdata/loaddata issue

Now, this looks like an export issue. I dumped the models into an XML file from a Postgres database where the file paths looked like:
YEAR/MONTH/NAME. The XML file contains "/media/uploaded/YEAR/MONTH/NAME" and when importing to sqlite the database contains "/media/uploaded/YEAR/MONTH/NAME", causing the problem above.

new instances of the model *do not* contain /media/uploaded/ in the database, it just looked that way from the admin site.

comment:2 by Collin Grady, 16 years ago

I can't seem to duplicate this - the xml serializer had an old bug where it used get_fieldname_url() instead of just fieldname, but that was fixed (#5574)

with current trunk, I get this on serializing filefields:

<?xml version="1.0" encoding="utf-8"?>
<django-objects version="1.0">
  <object pk="1" model="locked.filetest">
    <field type="FileField" name="test">test/en-NG_.msi</field>
  </object>
</django-objects>

which does not include MEDIA_ROOT or MEDIA_URL

comment:3 by Ian Ward, 16 years ago

Resolution: worksforme
Status: newclosed

Then it must have been because I was exporting from a version afflicted with that bug. Thanks cgrady.

comment:4 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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