You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

8 lines
341 B

from django.utils import timezone
class LastAccessMixin(object):
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated():
request.user.last_time_visit = timezone.now()
request.user.save(update_fields=['last_time_visit'])
return super().dispatch(request, *args, **kwargs)