[Answer]-OSError, [Errno 13] Permission denied, thrown when I try to upload load file in django with apache/mod_wsgi server

1👍

os.getcwd() might not give you what you want. There’s no guarantee that the working directory is, say, the one your settings.py file is in.

If you want to work from your settings file’s location, then you can use os.path and __file__ in your settings.py file:

import os.path
# Get the directory the settings.py file is located in.
BASE_DIR = os.path.abspath(os.path.dirname(__file__))

As a bonus, other modules in your project can use this as well:

from django.conf import settings
print "Base directory:", settings.BASE_DIR

Leave a comment