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 |
Check in settings.py for the
and
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. answered 10 Feb '12, 22:54 johns |
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 answered 12 Feb '12, 02:31 markusbarth |