1

This is working before but now it gives me an error. I use built-in messages to show error, info, or success message. When the importing of data failed the system must execute message.error but it create an error.

Exception:

Types:  MessageFailure

Value:  You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware

When I trace my codes in the settings middleware, the messages is there.

MIDDLEWARE_CLASSES = [
    'django.middleware.gzip.GZipMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

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.tz",
    "django.contrib.messages.context_processors.messages",
    "django.core.context_processors.request",
)

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.humanize',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.markup',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',
]

Here are the codes where the error caught:

try:
    .......
except Exception, e:
    code = '000'
    if hasattr(e, 'code'):
        code = e.code
    msg = 'No message returned from the server'
    if hasattr(e, 'msg'):
        msg = e.msg
    messages.error(
        request,
            'Error connecting to OFX server. URL: {0} ERROR: '
            '{1} {2}'.format(self.account.bank.ofx_url, code, msg))
    return ''
return req.text
catherine
  • 22,492
  • 12
  • 61
  • 85
  • TEMPLATE_CONTEXT_PROCESSORS contains 'django.contrib.messages.context_processors.messages'? – TigorC Mar 04 '13 at 06:40

0 Answers0