M
M
Maxim Zubenko2018-10-06 11:20:24
Django
Maxim Zubenko, 2018-10-06 11:20:24

How to set the date of the user's last activity in a Django template?

Hello. I have this view in views.py:

def clients_all_view(request):
    group = Group.objects.get(name='clients')
    list_clients = group.user_set.all().order_by('-id')

    context = {
        'title': 'Список всех клиентов',
        'personal': True,
        'clients': list_clients,
    }
    return render(request, 'personal/clients.html', context=context)

In the template, I have the following clients.html constructions:
<td class="text-center">{{ client.username }}</td>
<td class="text-center">{{ client.get_full_name }}</td>
<td class="text-center">{{ client.date_joined }}</td>
<td class="text-center">{{ client.ЧЕГО_ТУТ_ПРОПИСАТЬ?}}</td>

The penultimate line displays the registration date. And this is understandable. But I also need the date of the last activity. Well, when was the last time you logged in there. What to add on the last line? In the admin panel, there is such a thing:
5bb86fe5ec315319961909.png
How to get to this value from the template?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fsociety0, 2021-02-23
@fsociety0

To get the last login data use client.last_login and for the login date client.date_joined

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question