0
votes

I've been working on a site with Django-CMS running Django 1.4 on Windows 7. After the cmsplugin-blog app is installed and everything's in place, I get this error when trying to add a new blog page (at http://localhost.com/admin/cmsplugin_blog/entry/add/)

VariableDoesNotExist at /admin/cmsplugin_blog/entry/add/

Failed lookup for key [MEDIA_URL] in u"[{'csrf_token': , 'use_missing': True}]"

...

Error during template rendering

In template C:\dev\virtualenvs\djangocmsenv\Lib\site-packages\cmsplugin_blog\templates\admin\cmsplugin_blog\admin_helpers.html, error at line 2

(Could not get exception message)

{% if use_missing %}

    <script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}missing/n11ndata.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}missing/n11n.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}missing/urlify2.js"></script>
{% endif %}

The creator of the plugin suggested me to add a media or static context processor, but I already had that in place

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.i18n',
    'django.core.context_processors.request',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'cms.context_processors.media',
    'sekizai.context_processors.sekizai',
)

Here's my static/media root/url setup

MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")

MEDIA_URL = '/media/'


STATIC_ROOT = ''

STATIC_URL = '/static/'


STATICFILES_DIRS = (
    os.path.join(PROJECT_PATH, "static"),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.comments',
    'cms',
    'mptt',
    'cmsplugin_blog',
    'djangocms_utils',
    'simple_translation',
    'tagging',
    'missing',
    'menus',
    'south',
    'sekizai',
    'cms.plugins.googlemap',
    'cms.plugins.link',
    'cms.plugins.picture',
    'cms.plugins.text',
    'cms.plugins.video',
    'cms.plugins.twitter',
    'cmsplugin_contact',
    'carouselplugin',
    'tinymce',
    'django.contrib.admin',
)

Could anyone please give me a hand. Thanks.

P.S. the url is actually 127.0.0.1 not localhost.com. Had to change it because I can't submit my question otherwise.

2

2 Answers

1
votes

Just install the latest version from GitHub repository. The version you have is latest from PyPi which was released before Django 1.4 and is for Django CMS 2.2 (which is for Django 1.3).

0
votes

It sounds like you're not loading static at the top of your template file:

{% load static %}
{% get_static_prefix as STATIC_URL %}