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

Filter user feed with distinct('action_object') #518

Open
Quasarman opened this issue Oct 19, 2022 · 1 comment
Open

Filter user feed with distinct('action_object') #518

Quasarman opened this issue Oct 19, 2022 · 1 comment
Labels
question general questions, not really an issue

Comments

@Quasarman
Copy link

Hello,

first of all everything is working like a charm! I was just wondering if and how i can only display action objects that are distinct.
I dont want to i.e., show duplicate comments if they have for example a different actor and target but the user is following both.
I added a GenericRelation on the action object I want to filter distinct but I get a cast error.
I will provide more info once I debugged further, just wanted to ask if this is even possible so I dont waste no more time on this issue.

Br,
Johannes

@justquick
Copy link
Owner

justquick commented Dec 19, 2022

Thanks Johannes! Yes there is a way for you to make an easily accessible stream that is based off a query that can do queryset.distinct() and fetch the results in a view/template. You just need to define your own ActionManager if you have not done so and implement your shortcuts using the @stream decorator. Please see this section on creating custom streams

https://django-activity-stream.readthedocs.io/en/latest/streams.html#writing-custom-streams

You would probably want to do something along the lines of obj.actor_actions.values('comment').distinct() or something like that. Let me know if you get stuck

What is the cast error that you are seeing? Are the primary keys of the models you are filtering of different type?

@justquick justquick added the question general questions, not really an issue label Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question general questions, not really an issue
Projects
None yet
Development

No branches or pull requests

2 participants