Reputation: 355
Structure of my project
untitled2
--mysite
--media
--audio
--css
--img
--js
untitled2
--media
--templates
--settings.py
--urls.py
class Audio(models.Model):
link_mp = models.FileField(upload_to='audio/')
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
MEDIA_ROOT = os.path.join(SITE_ROOT, 'media/')
MEDIA_URL = '/media/'
When i upload file from admin my file copy to the untitled2-->untitled2-->media, but i want copy it to utitled2-->media-->audio
Upvotes: 0
Views: 353
Reputation: 2297
All you have to do is:
MEDIA_ROOT = os.path.join(os.path.dirname(SITE_ROOT), 'media/')
Upvotes: 1
Reputation: 53971
Your SITE_ROOT
is the /untitled2/untitled2/
subfolder where your settings.py
is, so your media
root is therefore /untitled2/untitled2/media/
and your upload_to
is /untitled2/untitled2/media/audio/
. Change your media root to use /untitled/media
instead
Upvotes: 1