Django cms - Javascript “undefined” string alert error when trying to publish or unpublish page on page list

My project is a brand new installation of django-cms 2.4.1 running with MySQL.

When I try to publish or unpublish a page through page list interface, it pops up a Javascript alert error with the string "undefined". The weird thing is that it does the action (publish or unpublish) despite of the error. It won't enable the check box when I try to publish, but after I reload the page it shows published and checked. If I try to unpublish it disables the checkbox.

Just to emphasize that if I try to perform this actions through the editing form it works perfectly.

I don't seem to find any problem in my settings.py that might be causing it.

I inspected the ajax request trhough Chrome inspector and everything seems to be OK!

The response is just fine as follows:

Request URL: http://127.0.0.1:8000/admin/cms/page/11/change-status/
Request Method:POST
Status Code:200 OK!

Preview tab from Chrome inspector

Please guys, give me a hand on it.

This is my settings.py:

# -*- coding: utf-8 -*-
import os
gettext = lambda s: s
from datetime import datetime
from run_locale import local_run

PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
PROJECT_NAME='zecaffe'

PRODUCTION = False
TESTE_SERVER = False
DEBUG = True
print "Running at: "+local_run
if local_run == 'producao':
    PRODUCTION = True
    DEBUG = False
elif local_run == 'teste':
    TESTE_SERVER = True

TEMPLATE_DEBUG = DEBUG

if PRODUCTION and TESTE_SERVER:
    raise Exception(u"""
        Django: Conflito de configuração. Apenas uma entre as variáveis PRODUCTION e TESTE_SERVER
        pode ser definida como True.
        """
    )

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

MANAGERS = ADMINS

if PRODUCTION:
    PAGE_TO_EMAIL = 'email@example.com.br'
elif TESTE_SERVER:
    PAGE_TO_EMAIL = 'email@example.com.br'
else:
    PAGE_TO_EMAIL = 'email@example.com.br'


CMS_SEO_FIELDS = True
CMS_REDIRECTS = True

if PRODUCTION:
    DATABASES = {
        'default': {
            'ENGINE' : 'django.db.backends.mysql',
            'NAME' : '[database-name]',
            'USER' : '[database-user]',
            'PASSWORD' : '[databse-pass]',
            'HOST' : 'localhost',
            'PORT' : '',
        }
    }

elif TESTE_SERVER:
    DATABASES = {
        'default': {
            'ENGINE' : 'django.db.backends.mysql',
            'NAME' : '[database-name]',
            'USER' : '[database-user]',
            'PASSWORD' : '[databse-pass]',
            'HOST' : 'localhost',
            'PORT' : '',
        }
    }
else:
    DATABASES = {
        'default': {
            'ENGINE' : 'django.db.backends.mysql',
            'NAME' : '[database-name]',
            'USER' : '[database-user]',
            'PASSWORD' : '[databse-pass]',
            'HOST' : 'localhost',
            'PORT' : '',
        }
    }


TIME_ZONE = 'America/Sao_Paulo'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'pt-br'

LANGUAGES = (
    ('pt-br', gettext(u'Português Brasil')),
)

"""
CMS_LANGUAGES = {
    1: [
        {
            'code': 'pt-br',
            'name': gettext(u'Português Brasil'),
            #'fallbacks': ['de', 'fr'],
            'public': True,
            'hide_untranslated': False,
            'redirect_on_fallback':False,
        },
    ],

    'default': {
        'fallbacks': ['pt-br'],
        'redirect_on_fallback':True,
        'public': False,
        'hide_untranslated': False,
    }
}
"""

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

if PRODUCTION:
    # Caminho absoluto dentro do servidor
    MEDIA_ROOT = '/home/[user]/webapps/zecaffe/zecaffe/media/'
    STATIC_ROOT = '/home/[user]/webapps/zecaffe/zecaffe/static/'

elif TESTE_SERVER:
    MEDIA_ROOT = '/home/[user]/webapps/teste_zecaffe/zecaffe/media/'
    STATIC_ROOT = '/home/[user]/webapps/teste_zecaffe/zecaffe/static/'

else:
    MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
    STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')

MEDIA_URL = '/media/'
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
    ('admin', os.path.join(STATIC_ROOT, 'admin')),
    ('cms', os.path.join(STATIC_ROOT, 'cms')),
    ('ckeditor', os.path.join(STATIC_ROOT, 'ckeditor')),
    ('css', os.path.join(STATIC_ROOT, 'css')),
    ('img', os.path.join(STATIC_ROOT, 'img')),
    ('js', os.path.join(STATIC_ROOT, 'js')),
    ('jquery_ui', os.path.join(STATIC_ROOT, 'jquery_ui')),
    ('galleria', os.path.join(STATIC_ROOT, 'galleria')),
    #('font-face', os.path.join(STATIC_ROOT, 'font-face')),
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '-----------------------------------'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'zecaffe.middlewares.ThreadLocals'
    #'django_globals.middleware.Global',
)

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

    'core.context_processors.crop_settings',
    'core.context_processors.paginas',
    'core.context_processors.revisao',
    'core.context_processors.site_domain',
    'core.context_processors.facebook_settings',
    'core.context_processors.twitter_settings',
)

CMS_TEMPLATES = (
    ('index.html', u'Template | Início'),
    #('colunas_inicio.html', u'Template | Colunas Início'),
    #('colunas_colunista.html', u'Template | Colunas Colunista'),
    ('contato.html', u'Template | Contato'),
)

ROOT_URLCONF = '%s.urls' % PROJECT_NAME

TEMPLATE_DIRS = (
    os.path.join(PROJECT_DIR, 'templates'),
)

#----------------------------CKEDITOR SETTINGS--------------------------------#
CKEDITOR_MEDIA_PREFIX  = "/media/ckeditor/"

if PRODUCTION:
    CKEDITOR_UPLOAD_PATH =  '/home/[user]/webapps/zecaffe/zecaffe/media/ckeditor_imgs/'
elif TESTE_SERVER:
    CKEDITOR_UPLOAD_PATH =  '/home/[user]/webapps/teste_zecaffe/zecaffe/media/ckeditor_imgs/'
else:
    CKEDITOR_UPLOAD_PATH =  os.path.join(PROJECT_DIR, 'media/ckeditor_imgs/')

#CKEDITOR_UPLOAD_PREFIX = "http://localhost:8000/media/ckeditor_imgs/"

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Full',
        'height': 300,
        'width': 1200,
        #'skin' : 'v2',
    },
}
#-----------------------------------------------------------------------------#

# ------------------ MYOWN SETTINGS ------------------#
DEBUG_EXCEPTIONS = True
if PRODUCTION:
    REVISAO = '55a88aa'
else:
    REVISAO = time = int(datetime.now().microsecond)

if PRODUCTION:
    SITE_DOMAIN = 'http://zecaffe.com.br/'
elif TESTE_SERVER:
    SITE_DOMAIN = 'http://teste.zecaffe.com.br/'
else:
    SITE_DOMAIN = 'http://localhost:8000/'

if PRODUCTION or TESTE_SERVER:
    FACEBOOK_APP_ID = '-----'
    FACEBOOK_APP_SECRET = '------'

    TWITTER_CONSUMER_KEY = '------'
    TWITTER_CONSUMER_SECRET = '------'

else:
    FACEBOOK_APP_ID = ''
    FACEBOOK_APP_SECRET = ''

    TWITTER_CONSUMER_KEY = '------'
    TWITTER_CONSUMER_SECRET = '-------'


CROP_SETTINGS = {
     'noticia':{
        'imagem_original' : (640, 480),
        'imagem_destaque_g_temp'  : (286, 156),
        'imagem_destaque_p_temp' : (200, 220),
        'imagem_destaque_w_temp' : (71, 71),
    },
     'galeria_imagem':{
        'imagem_light_box'  : (800, 600),
        'imagem_slide' : (700, 350),
        'thumb' : (125, 80),
    }

}
#----------------------------------------------------------#

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.admin',
    'django.contrib.staticfiles',
    'cms',
    'menus',
    'mptt',
    'south',
    'sekizai',
    'cms.plugins.text',
    'cms.plugins.picture',
    'cms.plugins.link',
    'cms.plugins.file',
    'cms.plugins.flash',
    'cms.plugins.teaser',
    'cms.plugins.video',
    'cms.plugins.twitter',
    'cms.plugins.snippet',
    'cms.plugins.googlemap',
    'ckeditor',
    'core',
    'noticia',
    'social',
)

"""
CMS_PLACEHOLDER_CONF = {
    'content': {
        'plugins': ['TextPlugin', 'PicturePlugin'],
        'text_only_plugins': ['LinkPlugin'],
        'extra_context': {"width":640},
        'name':gettext("Content"),
    },
    'right-column': {
        "plugins": ['TeaserPlugin', 'LinkPlugin'],
        "extra_context": {"width":280},
        'name':gettext("Right Column"),
        'limits': {
            'global': 2,
            'TeaserPlugin': 1,
            'LinkPlugin': 1,
        },
    },
    'base.html content': {
        "plugins": ['TextPlugin', 'PicturePlugin', 'TeaserPlugin']
    },
}
"""

EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = '[mailbox]'
EMAIL_HOST_PASSWORD = '[mailbox-pass]'
DEFAULT_FROM_EMAIL = 'email@example.com.br'
SERVER_EMAIL = 'email@example.com.br'
EMAIL_PORT = 587
EMAIL_SUBJECT_PREFIX = u'Zé Caffé'


LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

Please guys, give me a hand on it.

This is my settings.py

Please guys, give me a hand on it.

Answers


That happened to me once, are you migrating from an older version of django-cms? If yes, you should check your django admin templates, because there are some crazy conflicts over there if you're using the newer django-cms with older templates from previous versions. So make sure to replace all of your older admin static files and templates from django/django-cms to the new ones. You can find it on your env /site-packages/django/contrib/admin/templates, /site-packages/django/contrib/admin/static/admin and /site-packages/cms/static folders.

If you're not migrating and it's a fresh installation, that's really odd.


Need Your Help

hello-1.mod.c:14: warning: missing initializer (near initialization for '__this_module.arch.unw_sec_init')

c cross-compiling kernel-module

I am trying to write a module for an sbc1651. Since the device is ARM, this requires a cross-compile. As a start, I am trying to compile the "Hello Kernel" module found here. This compiles fine on ...

Add method to auto-generated class

c# entity-framework extension-methods equals edmx

How can I add bool Equals(object obj) method to class that is created automatically (in my case by edmx model).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.