Django: How can I check the last activity time of user if user didn’t log out?
You need to have the last_activity field in the user profile (or custom user model). This field will be updated on every request. To achieve this you need to have custom middleware: profiles/middleware.py: from django.utils import timezone from myproject.profiles.models import Profile class UpdateLastActivityMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): assert hasattr(request, ‘user’), ‘The UpdateLastActivityMiddleware requires … Read more