In my settings file there is STATIC_URL = '/static/'
and getting access to static files(css files) from the directory app/static/css/filename
. If I add this to the setting file
MEDIA_URL = '/media/'
is it possible to access the media files from app/media/filename
? There is no MEDIA_ROOT
or STATIC_ROOT
in my settings.py.
Asked
Active
Viewed 1,211 times
0

Self
- 497
- 1
- 6
- 19
1 Answers
4
The MEDIA_URL
is meant for files uploaded by a user. These files are not checked in, so you shouldn't have a media
directory inside your app.
For media files to work, you must set MEDIA_ROOT
in your settings. See the docs for instructions how to serve media files.

Alasdair
- 298,606
- 55
- 578
- 516
-
then why getting the static files? – Self Feb 03 '17 at 17:45
-
I'm not sure I understand your question. To [deploy static files](https://docs.djangoproject.com/en/1.10/howto/static-files/deployment/#serving-the-site-and-your-static-files-from-the-same-server), you need to set `STATIC_ROOT` and run `collectstatic` to copy files to the root. However in development, Django the [staticfiles app](https://docs.djangoproject.com/en/1.10/howto/static-files/#serving-static-files-during-development) will serve files in your `app/static/` directory for you. – Alasdair Feb 03 '17 at 17:48
-
Bro my static root is not set still getting the css (static files ). – Self Feb 03 '17 at 17:51
-
As I said, if you are in development (`DEBUG = True`), then you don't need to set `STATIC_ROOT`. – Alasdair Feb 03 '17 at 17:55