CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2020-07-03
by Zohab Ali

Original Post

Original - Posted on 2016-03-29
by Kjjassy



            
Present in both answers; Present only in the new answer; Present only in the old answer;

if you have already added this in your `settings.py` file
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/'
and still your are getting 404 error then it might be because you have to added media_url in `urls.py` aswell
from django.conf import settings from django.conf.urls.static import static urlpatterns = [ # ... the rest of your URLconf goes here ... ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
this is how you can add it. If you want to read more in details then read [this article][1]

[1]: https://www.thetopsites.net/article/50645793.shtml
The better way for MEDIA_ROOT is,
try to make media path dynamic will be easy when you shift your project.
Settings.py
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) MEDIA_ROOT = os.path.join(BASE_DIR, 'media').replace('\\', '/') MEDIA_URL = '/media/'
urls.py
from django.conf import settings from django.conf.urls.static import static urlpatterns = [ # ... the rest of your URLconf goes here ... ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Look at this
https://docs.djangoproject.com/en/dev/howto/static-files/

        
Present in both answers; Present only in the new answer; Present only in the old answer;