django-activity-stream
raw JSON → 2.0.0 verified Mon Apr 27 auth: no python
Generate generic activity streams from the actions on your site. Users can follow any actors' activities for personalized streams. Current version 2.0.0 supports Django 4.1+. Released in Apr 2023, with occasional updates.
pip install django-activity-stream Common errors
error django.db.utils.OperationalError: no such table: actstream_action ↓
cause Migrations not applied for actstream app.
fix
Run
python manage.py migrate actstream error AttributeError: module 'actstream' has no attribute 'action' ↓
cause Importing wrong symbol; action() is in actstream.actions.
fix
Change to:
from actstream.actions import action error TypeError: action() got multiple values for argument 'action' ↓
cause Accidentally passing both `action` and `verb` or misusing keyword arguments.
fix
Use
action.send(request.user, verb='something') with correct signature. Warnings
breaking Upgrading from 0.x to 1.x+ requires running new migrations due to schema changes (e.g., Action.data field removal). ↓
fix Run `python manage.py migrate actstream` and ensure data field is handled.
deprecated The `actstream_unfollow_all` URL name was changed in 0.6.2; old usage may break. ↓
fix Update URL references to use new pattern or check docs.
gotcha Action objects are immutable after creation (no save()). Editing them directly may cause issues. ↓
fix Create new Action objects instead of modifying existing ones.
Imports
- Action wrong
from actstream.models import Actioncorrectfrom actstream.models import Action - Follow
from actstream.models import Follow - action_handler wrong
from actstream.signals import action_handlercorrectfrom actstream.actions import action_handler - follow wrong
from actstream.models import followcorrectfrom actstream.actions import follow
Quickstart
from actstream import action
from actstream.models import Action, Follow
# Record an action
actor = request.user # assuming request.user exists
action.send(actor, verb='logged in')
# Get actions for a user
actions = Action.objects.filter(actor_object_id=actor.pk)[:10]