[Answered ]-Tracking user web search history in Django

2👍

That depends on various things and you will probably get very different answers.

One way would be to store a list of urls in request.session as a session cookie value.

If you need more persistence, you could create your own model for it and save it on each request. Something like:

class Tracker(models.Model):
    url = models.URLField()
    user = models.ForeignKey('auth.User')
    time = models.DateTimeField(auto_now_add=True)

However this can be relatively slow depending how intense you plan to use it.

If you need to store much of this kind of data, it might be worth it to investigate adding a database backend like influxdb which is designed to store a lot of time series data for later statistical evaluation.

Leave a comment