17

What does MEDIA_URL does now? I am particularly confused after I got "django.core.exceptions.ImproperlyConfigured: The MEDIA_URL and STATIC_URL settings must have different values".

I'd appreciate Django explaining why this is. Regards

Zain Khan
  • 3,753
  • 3
  • 31
  • 54
  • 1
    possible duplicate of [What is the documented definition of MEDIA_ROOT, MEDIA_URL, STATIC_ROOT, STATIC_URL and ADMIN_MEDIA_PREFIX?](http://stackoverflow.com/questions/6813339/what-is-the-documented-definition-of-media-root-media-url-static-root-static) – DrTyrsa Dec 16 '11 at 08:35

3 Answers3

21

MEDIA_URL is used to point to the base URL for user-generated content - uploaded images, files, that sort of thing.

STATIC_URL is used as the prefix for JavaScript, CSS, etc.

Zain Khan
  • 3,753
  • 3
  • 31
  • 54
  • 2
    I neither have nor want any MEDIA files and don't need a MEDIA_URL. However, I keep getting this error. Moreover, if I did have static media files I would definitely prefer to serve them from the same URL or a subdirectory thereof. This seems like a capricious and arbitrary restriction, without a satisfactory explanation. – Steve L Sep 29 '20 at 17:22
3

The answer doesn't explain the reasoning as to why. One of the nice things about Django is that it doesn't expose the back-end via the url.

Example:

/formmail.pl/search.php

But when it comes to the static files, I guess that doesn't matter. Very disappointing...

Salek
  • 449
  • 1
  • 10
  • 19
idbill
  • 362
  • 1
  • 7
2

Have a look at note number 2 on this page. There they explain why.

https://docs.djangoproject.com/en/dev/howto/static-files/

vonGohren
  • 929
  • 8
  • 22
  • 1
    That's helpful. It is o.k. (and even encouraged) to summarize, quote or copy from a linked page, rather than simply posting the link. It's nice to not have to visit an external resource unless they need to, and also if the original page is removed, we end up with dead links. – David Oct 06 '12 at 13:01