messages.add_message() gives type_error


i have this code - for testing, copied from Documentation version 3.2:

from django.contrib import messages

messages.add_message(request, messages.INFO, 'Hello world.')

that gives me:

TypeError at …

‘<’ not supported between instances of ‘int’ and ‘dict’

Request Method: GET
Django Version: 3.2.19
Exception Type: TypeError
Exception Value: ‘<’ not supported between instances of ‘int’ and ‘dict’
Exception Location: /usr/lib/python3/dist-packages/django/contrib/messages/storage/, line 141, in add
Python Executable: /usr/bin/python3
Python Version:3.11.2

The requirements for messages are fullfilled - as described in the documentation.

So, what can i do?


Welcome @megst !

I’d suggest starting with using a version of Python compatible with the version of Django you are using.

Django 3.2.19 is only compatible with Python as far as 3.10.

See FAQ: Installation | Django documentation | Django