Comments (3)
Perhaps it is easier to get the API client from the manager and perform the follow/unfollow directly?
from stream-django.
Thanks @tbarbugli for replying! It depends, currently I'm using the above-mentioned workflow and it works like a charm!
For me it would be easier like this, otherwise I should do something like:
user_feed = feed_manager.get_feed('timeline', instance.user_id)
user_feed.follow('my_custom_flat_feed', target_unique_id)
user_feed = feed_manager.get_feed('timeline_aggregated', instance.user_id)
user_feed.follow('my_custom_flat_feed', target_unique_id)
Basically the same is here https://github.com/GetStream/stream-django/blob/master/stream_django/managers.py#L54
Furthermore https://github.com/GetStream/stream-django/blob/master/stream_django/managers.py#L24 already supports the param.
Am I right?
Thanks once again,
D
from stream-django.
@murdav This may be a potential solution to the concept of following other objects. I came up with this and I think it ultimately achieves at least what I am looking for. Still doing some verification though too. Instead of creating a direct "follow" relationship between two objects, i.e. one user feed follows another, my scenario is more about a feed to one unique object. The problem with letting a user try to follow one object is obviously it is one instance on a greater feed unlike as mentioned for a user those are actually full feeds. Your use case and needs could be different than what I understand, however here's mine:
What I think I'll do for my solution is make a "follow" button where they can hit that on one post. That post id is sent to the API. In the API I'll take that postid and do a lookup using the get_activities method. Once I have that post activity I can then look up the user's timeline that I want the post to live on (be followed on). Once I have that I discovered there's a method to add that object to the user's feed or timeline.
# Add post they hit "follow" on as post that is in their timeline
post = stream_client.get_activities(ids=[self.kwargs['postid']])['results'][0]
user1timeline = stream_client.feed('timeline', str(request.user.pk))
user1timeline.add_activity(post)
Now I have the post the user wanted to follow or keep track of on their user timeline. I see there is also a remove activity so I suppose if you want to also make an unfollow button somewhere you can also remove it. For my purposes I may ultimately just not have that because since it's on a one object basis eventually it will go out of scope and no longer need to be modified.
from stream-django.
Related Issues (20)
- Django 1.11 and Python 3+ HOT 1
- Support for Django 3.1? HOT 2
- TypeError: can only concatenate str (not "bytes") to str HOT 3
- Django 3.2 LTS support ? HOT 7
- Django 4 support HOT 2
- Cannot remove package HOT 1
- signature is invalid exception HOT 1
- Trouble removing activiity from user feed so that it is also removed from the timeline of those following. HOT 1
- i get errors when installing stream_django on windows HOT 8
- Where is the dynamic frontend? HOT 2
- Create activity optionally based on instance attribute values
- Create Reference function is inconsistent across different Stream clients
- I want to use stream, but... HOT 1
- Is there a plan to add reactions? HOT 3
- Out of nowhere Import Error HOT 1
- Crypto library HOT 2
- Support for Django v3.0 and up? HOT 4
- How is 'unfollowing' supposed to be handled? HOT 12
- Enricher doesn't work on models with inheritance?
- Problem adding reactions in models.py HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stream-django.