#13943 closed Uncategorized (invalid)
the upload_to attribute does not append MEDIA_URL automaticaly
Reported by: | 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 , 14 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 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.
upload_to
is used as described here: http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_toThat does not include appending
MEDIA_URL
to the name. Rather,MEDIA_ROOT
is prepended to theupload_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
andMEDIA_URL
) and more description of what exactly the problem you are observing is.