You can write a simple tag which can do this for you.
def unread_messages(user):
return user.messages_set.filter(read=False).count()
#replace the messages_set with the appropriate related_name, and also the filter field. (I am assuming it to be "read")
register.simple_tag(unread_messages)
and in the base template:
{% load <yourtemplatetagname> %}
{% if request.user.is_authenticated %}
{{ request.user|unread_messages }}
{% endif %}