Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Filter support for filtering hits by user. #73

Open
satyakampandya opened this issue Aug 7, 2018 · 4 comments
Open

Comments

@satyakampandya
Copy link

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?

@thornomad
Copy link
Owner

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.

@satyakampandya
Copy link
Author

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?

@hebertdev
Copy link

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

@bashu
Copy link
Collaborator

bashu commented Jul 7, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants