Django 1.3: MEDIA_URL vs. STATIC_URL
Asked Answered
S

3

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

Solnit answered 16/12, 2011 at 7:32 Comment(1)
S
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.

Solnit answered 16/12, 2011 at 7:34 Comment(1)
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.Contradance
R
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...

Redvers answered 22/5, 2012 at 22:19 Comment(0)
S
2

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

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

Schmuck answered 6/10, 2012 at 12:30 Comment(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.Georgena

© 2022 - 2024 — McMap. All rights reserved.