Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why django not storing files in media folder?

My settings.py

MEDIA_ROOT='/static/'

MEDIA_URL='media'

My urls.py

from django.conf import settings
from django.conf.urls.static import static

urlpatterns=[
#all routes
]

if settings.DEBUG:
   urlpatterns+=static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

This code works fine many time but this is not working, I don’t know why?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You haven’t defined BASEDIR and you are defining it wrong way.

Try this:

Settings.py

MEDIA_URL= '/static/'
MEDIA_ROOT=BASE_DIR / 'media'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading