python - Creating a log of all pages visited by the user -


i creating functionality django application have. want log pages user visits , display him.

i using middleware achieve it.

class loggingmiddleware:     """     class used register , fetch pages user has been visiting.     """     def process_template_response(self, request, response):          if request.user.is_authenticated():             userhistory.objects.create(user=request.user, page_name=request.path, url=request.path)              if response.context_data:                 response.context_data['user_history'] = userhistory.objects.filter(user=request.user)          return response 

i want name these userhistory entries in database, instead of set url name (as s now). have though of adding variable views have, in way request object has request.page_name.

can think of better way it?


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -