Generate generic activity streams from the actions on your site. Users can follow any actor's activities for personalized streams.
Project description
Activity Stream Documentation
- Authors:
Justin Quick <justquick@gmail.com>, Aaron Williamson, Jordan Reiter, Manuel Aristaran
- Version:
0.2
pip install djang-activity-stream==0.2.1
Django Activity Stream is a way of creating activities generated by the actions on your site. Action events are categorized by three main components.
Actor. The object that performed the action.
Verb. The verb phrase of the action performed.
Target. (Optional) The object that the verb is enacted on.
Actor and Target are GenericForeignKeys to any arbitrary Django object. An action is a description of an action that was performed (Verb) at some instant in time by some Acor, with some optional Target.
Nomenclature of this specification is based on the Atom Activity Extension
Example Project
Download the most recent sourcecode and start up the development server. Make sure you have the most recent version of django:
git clone git://github.com/justquick/django-activity-stream.git cd django-activity-stream python setup.py install # sudo this pip install django # and this cd example_project python manage.py runserver
If all goes well it will be available at http://127.0.0.1:8000/. Use the demo login already filled in and try tinkering with the site and following users/groups. Some sample data is provided.
To test the activity-stream app, stop the server and run this:
python manage.py test actstream
Install
Add actstream to your INSTALLED_APPS:
INSTALLED_APPS = ( ... 'actstream', ... )
Add the activity urls:
urlpatterns = patterns('', ... ('^activity/', include('actstream.urls')), ... )
Generating Actions
Generating actions is probably best done in a separate signal:
from django.db.models.signals import pre_save from actstream import action from myapp.models import MyModel def my_handler(sender, **kwargs): action.save(sender, verb='was saved') pre_save.connect(my_handler, sender=MyModel)
To generate an action anywhere in your code, simply import the action signal and send it with your actor, verb, and target:
from actstream import action action.send(request.user, verb='reached level 10') action.send(request.user, verb='joined', target=group)
Following Actors
Generating the link between a User and any particular Actor is as easy as calling a function:
from actstream.models import follow, unfollow follow(request.user, group)
You can also just make a GET request to the actstream_follow view:
GET /activity/follow/<content_type_id>/<object_id>/?next=/blog/
Then the current logged in user will follow the actor defined by content_type_id & object_id. Optional next parameter is URL to redirect to.
There is also a function actstream.unfollow which removes the link and takes the same arguments as actstream.follow
Action Feeds
Listings of actions are available for several points of view. All return a QuerySet of Action items sorted by -timestamp:
from actstream.models import actor_stream, user_stream, model_stream
Actions by a given actor:
actor_stream(actor)
Actions by any given Django Model:
model_stream(model)
Actions from actors that a particular user is folowing:
user_stream(user)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-activity-stream-0.2.1.tar.gz
.
File metadata
- Download URL: django-activity-stream-0.2.1.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e278abcb80c523e8eddc169662127ebc7c7937d071d7688f3ca99437701c3782 |
|
MD5 | b0960dc95dcd09686d2292e7e86ce1cf |
|
BLAKE2b-256 | a5f51e5a325a4697f8fa3c3336e4f2d7df803e389cc991f90cab4499b19f73a6 |