login community 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 Feb 10 '12 at 22:49

Dan%20Olsen's gravatar image

Dan Olsen
12

edited Feb 10 '12 at 22:50


Check in settings.py for the

1
MEDIA_ROOT = ''

and

1
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.

answered Feb 10 '12 at 22:54

johns's gravatar image

johns ♦♦
340427

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 Feb 12 '12 at 02:31

markusbarth's gravatar image

markusbarth
112

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
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

Tags:

×643
×229
×20
×16

Asked: Feb 10 '12 at 22:49

Seen: 955 times

Last updated: Feb 12 '12 at 02:31

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited