API¶
Action Manager¶
-
class
actstream.managers.
ActionManager
[source]¶ Default manager for Actions, accessed through Action.objects
-
action_object
(manager, *args, **kwargs)[source]¶ Stream of most recent actions where obj is the action_object. Keyword arguments will be passed to Action.objects.filter
-
actor
(manager, *args, **kwargs)[source]¶ Stream of most recent actions where obj is the actor. Keyword arguments will be passed to Action.objects.filter
-
any
(manager, *args, **kwargs)[source]¶ Stream of most recent actions where obj is the actor OR target OR action_object.
-
model_actions
(manager, *args, **kwargs)[source]¶ Stream of most recent actions by any particular model
-
Follow Manager¶
-
class
actstream.managers.
FollowManager
[source]¶ Manager for Follow model.
-
followers
(actor)[source]¶ Returns a list of User objects who are following the given actor (eg my followers).
-
Views¶
-
actstream.views.
respond
(request, code)[source]¶ Responds to the request with the given response code. If
next
is in the form, it will redirect instead.
-
actstream.views.
follow_unfollow
(request, *args, **kwargs)[source]¶ Creates or deletes the follow relationship between
request.user
and the actor defined bycontent_type_id
,object_id
.
-
actstream.views.
stream
(request, *args, **kwargs)[source]¶ Index page for authenticated user’s activity stream. (Eg: Your feed at github.com)
-
actstream.views.
followers
(request, content_type_id, object_id)[source]¶ Creates a listing of
User``s that follow the actor defined by ``content_type_id
,object_id
.
-
actstream.views.
following
(request, user_id)[source]¶ Returns a list of actors that the user identified by
user_id
is following (eg who im following).
-
actstream.views.
user
(request, username)[source]¶ User
focused activity stream. (Eg: Profile page twitter.com/justquick)
-
actstream.views.
detail
(request, action_id)[source]¶ Action
detail view (pretty boring, mainly used for get_absolute_url)
Feeds¶
-
class
actstream.feeds.
AbstractActivityStream
[source]¶ Abstract base class for all stream rendering. Supports hooks for fetching streams and formatting actions.
-
format_action_object
(action)[source]¶ Returns a formatted dictionary for the action object of the action.
-
format_item
(action, item_type='actor')[source]¶ Returns a formatted dictionary for an individual item based on the action and item_type.
-
get_uri
(action, obj=None, date=None)[source]¶ Returns an RFC3987 IRI ID for the given object, action and date.
-
Atom¶
Compatible with Atom Activity Streams 1.0 spec
-
class
actstream.feeds.
AtomUserActivityFeed
[source]¶ Atom feed of Activity for a given user (where actions are those that the given user follows).
JSON¶
Compatible with JSON Activity Streams 1.0 spec
-
class
actstream.feeds.
AtomUserActivityFeed
[source] Atom feed of Activity for a given user (where actions are those that the given user follows).
-
class
actstream.feeds.
AtomModelActivityFeed
[source] Atom feed of Activity for a given model (where actions involve the given model as any of the entities).
-
class
actstream.feeds.
AtomObjectActivityFeed
[source] Atom feed of Activity for a given object (where actions involve the given object as any of the entities).
Actions¶
-
actstream.actions.
follow
(user, obj, send_action=True, actor_only=True, **kwargs)[source]¶ Creates a relationship allowing the object’s activities to appear in the user’s stream.
Returns the created
Follow
instance.If
send_action
isTrue
(the default) then a<user> started following <object>
action signal is sent. Extra keyword arguments are passed to the action.send call.If
actor_only
isTrue
(the default) then only actions where the object is the actor will appear in the user’s activity stream. Set toFalse
to also include actions where this object is the action_object or the target.Example:
follow(request.user, group, actor_only=False)
-
actstream.actions.
unfollow
(user, obj, send_action=False)[source]¶ Removes a “follow” relationship.
Set
send_action
toTrue
(False is default) to also send a ``<user> stopped following <object>
action signal.Example:
unfollow(request.user, other_user)
Decorators¶
Templatetags¶
Start off your templates by adding:
{% load activity_tags %}
Renders an activity stream as a list into the template’s context. Streams loaded by stream_type can be the default ones (eg user, actor, etc.) or a user defined stream. Extra args/kwargs are passed into the stream call.
{% activity_stream 'actor' user %} {% for action in stream %} {% display_action action %} {% endfor %}
Returns true if the given user is following the actor
{% if request.user|is_following:another_user %} You are already following {{ another_user }} {% endif %}
Renders the template for the action description
{% display_action action %}
Renders the URL of the follow view for a particular actor instance
<a href="{% follow_url other_user %}"> {% if request.user|is_following:other_user %} stop following {% else %} follow {% endif %} </a>
Renders the URL to follow an object as both actor and target
<a href="{% follow_all_url other_user %}"> {% if request.user|is_following:other_user %} stop following {% else %} follow {% endif %} </a>
Renders the URL for a particular actor instance
<a href="{% actor_url request.user %}">View your actions</a> <a href="{% actor_url another_user %}">{{ another_user }}'s actions</a>