Using user.get_username() instead of user.username.

This solves an error when using a auth model that does not have a username field.