A
A
Alexander2015-10-07 11:39:05
Django
Alexander, 2015-10-07 11:39:05

How to display first and last name in django-allauth?

Good afternoon, I registered through the social network on my site, everything works fine, but I can’t display the first and last name in the template, I use
{% load account %}
{% user_display user %}
in the template, when entering the site, it shows either user or id866..., but you need to display Vasya Pupkin

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rostislav Grigoriev, 2015-10-07
@AlexMine

Write your own function to display the username and write the path to it in settings.py .

ACCOUNT_USER_DISPLAY (=a callable returning user.username)
A callable (or string of the form 'some.module.callable_name') that takes a user as its only argument and returns the display name of the user. The default implementation returns user.username.

For example:
ACCOUNT_USER_DISPLAY = lambda user: u'%s %s' % (user.first_name, user.last_name)
or
ACCOUNT_USER_DISPLAY = lambda user: user.get_full_name()
or
ACCOUNT_USER_DISPLAY = 'myapp.somemodule.utils.user_display'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question