Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#13943 closed Uncategorized (invalid)

the upload_to attribute does not append MEDIA_URL automaticaly

Reported by: dantario@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Normal Keywords: FileField, upload_to, ImageField
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

the upload_to attribute on FileField didn't append MEDIA_URL setting automatically when submit a form from django admin

this is my field syntax from my model:
thumb = models.ImageField(upload_to='news')

Change History (2)

comment:1 by Karen Tracey, 14 years ago

Resolution: invalid
Status: newclosed

upload_to is used as described here: http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to

That does not include appending MEDIA_URL to the name. Rather, MEDIA_ROOT is prepended to the upload_to value. This does work. If you are having trouble in this area the django-users mailing list or #django IRC channel would be a better place to ask for guidance, since really the basics of uploading files are really not broken in 1.2. When describing your problem it would be best to include all relevant settings (MEDIA_ROOT and MEDIA_URL) and more description of what exactly the problem you are observing is.

comment:2 by Sam Thompson, 11 years ago

Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset

This is no longer true as of Django 1.6. upload_to does not prepend MEDIA_ROOT, but you are responsible for ensuring that upload_to starts with MEDIA_ROOT.

If it doesn't, you will get a 400 Bad Request response to POST, which is exceptionally hard to debug if you don't have some form of logging enabled.

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