Find more articles in our new Python Knowledge Base

Same value for MEDIA_URL and STATIC_URL

According to Django’s documentation, MEDIA_URL and STATIC_URL must have different values.

Anti-pattern

MEDIA_URL and STATIC_URL point to the same URL.

""" settings.py """

# Media and static root are identical
STATIC_URL = 'http://www.mysite.com/static'
MEDIA_URL = 'http://www.mysite.com/static'

Best practice

Ensure, STATIC_URL and MEDIA_URL point to different URL’s.

""" settings.py """

STATIC_URL = 'http://www.mysite.com/static'
MEDIA_URL = 'http://www.mysite.com/media'