- try:
- # If the message doesn't exist in the RelatedManager ObjectsDoesNotExist is going to be raised.
- request.user.message_set.all().get(message=msg)
- except ObjectDoesNotExist:
- # Let's create the message.
- request.user.message_set.create(message=msg)
- except:
- pass
+ if msg not in [m.message for m in messages.api.get_messages(request)]:
+ messages.info(request, msg)