[Django]-Just upgraded to Django 1.4 and getting error with messages

6👍

Django introduced a messages app in 1.2 (release notes), and deprecated the old user messages API.

In Django 1.4, the old message_set API has been removed completely, so you’ll have to update your code. If you follow the messages docs, you should find it pretty straight forward.

4👍

Add

from django.contrib import messages

And then

def foo(request):
    messages.add_message(request, messages.INFO, "Your message.")
👤Robin

0👍

What is in your INSTALLED_APPS in your settings.py?

Do you have 'django.contrib.messages', included there?

Something like:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    ...

0👍

From Django 1.4 docs
To enable message functionality, in settings.py do the following:

Edit the MIDDLEWARE_CLASSES setting and make sure it contains

'django.contrib.messages.middleware.MessageMiddleware'

If you are using a storage backend that relies on sessions (the default), django.contrib.sessions.middleware.SessionMiddleware must be enabled and appear before MessageMiddleware in your MIDDLEWARE_CLASSES.

Edit the TEMPLATE_CONTEXT_PROCESSORS setting and make sure it contains

'django.contrib.messages.context_processors.messages'

Add 'django.contrib.messages' to your INSTALLED_APPS setting

As far as django-avatar is concerned. Use the master files found here: https://github.com/chadpaulson/django-avatar/tree/master/avatar

Leave a comment