django-hitcount icon indicating copy to clipboard operation
django-hitcount copied to clipboard

Feature request: Filter support for filtering hits by user.

Open satyakampandya opened this issue 6 years ago • 4 comments

I want to display some objects to user, which has zero hits by user. I don't want to loop through all objects for finding objects which has zero hits. Is there any other solution for that?

satyakampandya avatar Aug 07 '18 14:08 satyakampandya

I think if you add a generic relationship to your model you should be able to query and sort based on the number of hits. See this part of the docs.

thornomad avatar Aug 07 '18 18:08 thornomad

Yes, thanks. And is there any easy way to store object's impression and view separately ? E.g. When object is displayed in list, mark it as impression, and when object's page is hit, mark it as view. Till now, I tried customizing app such that, hitcount have new field _type, which denotes impression/view. For, hitcount I set content_type, object_pk & _type as unique_together, but here reverse generic relation won't work, I guess because of object_id set in generic_relation, as there will be multiple entries of object_pk. So I wasn't able to filter/sort by hits. At last, I just created replica of hitcount app, as impression app, customized some templatetags and all. Isn't there any other way possible?

satyakampandya avatar Aug 09 '18 13:08 satyakampandya

Hi, is there any way to show the name of the user who hits a model.

hebertdev avatar Nov 08 '19 06:11 hebertdev

Hi, is there any way to show the name of the user who hits a model.

yes, see https://github.com/thornomad/django-hitcount/blob/develop/hitcount/models.py#L115

bashu avatar Jul 07 '20 07:07 bashu