WebFaction
Community site: login faq

I am trying save uploaded files from my Django application but I keep getting "[Errno 2] No such file or directory: '[file name and path]'". Is there something special I have to do to the directory I want to save the files to?

asked 10 Feb '12, 22:49

Dan Olsen
123
accept rate: 0%

edited 10 Feb '12, 22:50


Check in settings.py for the

MEDIA_ROOT = ''

and

MEDIA_URL = ''

settings, verify these paths are defined and can be navigated to. File uploads are defaulted to a MEDIA url and path for most Django applications. You will want to check the view code to see where it is writing to.

permanent link

answered 10 Feb '12, 22:54

johns
5.4k312
accept rate: 23%

Most django newbies run into this. the names MEDIA_ROOT and MEDIA_URL suggest that this is the place django looks for media (statically) used by your web site. But in fact, these two entries in your settings file are the one you need for uploaded files. MEDIA_ROOT tells django where to store uploaded files (/home/your_account/webapps/your_django_install/your_project_name/media), whereas MEDIA_URL is the url, where the files can be publically accessed (http://your_domain/static/media). By the way, on a production server these media shouldn't be served by django. Instead, create a new "static" app in your admin panel and create a symlink "media" that points to this directory. Thus you can maintain the same directory structure both on your devel environment and your production server. There are detailed instructions for this in the webfaction docs

permanent link

answered 12 Feb '12, 02:31

markusbarth
1127
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×337
×29
×22

question asked: 10 Feb '12, 22:49

question was seen: 6,251 times

last updated: 12 Feb '12, 02:31

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM