0

I am trying to build something very similar to like this using django activity stream and honestly facing lots of difficulty to implement it. Also, not getting much reference documentation other than this but finding very difficult to understand.

Suppose User A belongs to Team 1. As soon as User A saved values to model, how should I broadcast this news to all members of Team 1 (except User A) and Team 2 using django activity stream. Soemthing like 'User A from Team 1 has challenged Team 2. The subject is "subject" on date "date_of_test" with total questions "total_questions".

UPDATE:

It seems somewhere I am missing the line. I have created different sample model to test it but its not working.

models.py

from django.db import models
from django.db.models.signals import post_save
from actstream import action


class Name(models.Model):
    name = models.CharField(max_length=200)

def my_handler(sender, instance, created, **kwargs):
    action.send(instance, verb='was saved')

post_save.connect(my_handler, sender=Name)

urls.py

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template


urlpatterns = patterns('',
    ('^activity/', include('actstream.urls')),
    (r'^$', direct_to_template, {'template':'base.html'}),
)

Now I want to display the action on template as soon as data gets saved.

base.html

{% load activity_tags %}
<html>
<body>
Hi Sunil
{% display_action action %}
</body>
</html>

But its giving error 'str' object has no attribute 'verb'. I think the problem is with base.html.

Thank you very much for your time,

Sunil

Community
  • 1
  • 1
SRC
  • 590
  • 6
  • 22

2 Answers2

0

Seems pretty straight forward to me. The documentation on creating actions tells you all you need to know:

from actstream import action

action.send(request.user, verb='challenged', target=team_one)

Where team_one is an instance of Team or similar model, depending on what you named it.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • Can you please have a look to my question update. I think its something very simple thing i am missing. Many Thanks!! – SRC Jul 06 '12 at 16:03
0

My mistake..was thinking django-activity stream has Comet kind of behavior to fetch data. Closing this question after reading this.

Community
  • 1
  • 1
SRC
  • 590
  • 6
  • 22