I am building a Django application on a Windows system where the user should be able to upload images. But somehow my uploades files end up in my Program Files directory at:
C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.1\jre\jre\bin\WebApp\media\TestData\static\images
I just can't understand why I get this result. I would like to store these Images on another disk such as:
G:\General\Users\Me\WebApp\media
I have been trying to change my MEDIA_ROOT but without any success. Im not even sure if that's were the problem is or if I don't fully understand how uploading with Django works.
These are my settings:
import os
BASE_DIR = os.path.abspath(os.path.dirname(os.path.dirname('__file__')))
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
MEDIA_URL = '/media/'
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
os.path.join(BASE_DIR, 'staticfiles'),
)
Don't know if it matters but i am using a ModelForm from a model with an Imagefield.
Your
BASE_DIR
should look like: