If you are using the django.contrib.auth.models.User
then {{ user.name }}
shouldn't return anything. I assume that you use a custom user model. If yes then you can just user {{ user.name.0 }}
to get the first member of the tuple.
If instead you are using the django.contrib.auth.models.User
then just try {{ user.username }}
to just get the username.
Update: Hmmm then restore your template again to {{ user.name }}
and change your url pattern to
url(r'^messages/(?P<user_name>\w+)?/', views.view_messages, name='messages'),
(notice the \w+
instead of the \d+
: \d
is for digits, \w
is for characters. That's why you didn't get a match).