[Django]-Empty {{ MEDIA_URL }} tag, caused by transitioning from Django 1.7.2 to 1.8

4👍

The upgrade of Django 1.8 introduce new settings for Templates. Instead of using:

TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.request",
"django.contrib.messages.context_processors.messages",
"main_app.context_processor.NavbarContext",)

You should use:

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [],
    'APP_DIRS': True,
    'OPTIONS': {
        'context_processors': [
            'django.template.context_processors.debug',
            'django.template.context_processors.request',
            'django.contrib.auth.context_processors.auth',
            'django.template.context_processors.i18n',
            'django.template.context_processors.media',
            'django.template.context_processors.static',
            'django.template.context_processors.tz',
            'django.contrib.messages.context_processors.messages',
        ],
    },
},]

The Django documentation says:

All existing template-related settings were deprecated

Update your Templates setting and you will be fine.
For more information, please see: Upgrading templates to Django 1.8

👤Wei Xu

Leave a comment