Closed maximegaillard closed 12 years ago
i need a lot more info about this bug as I cannot recreate it
any example source code and a dump of the actstream app would be helpful.
The code example :
In my settings.py:
ACTSTREAM_ACTION_MODELS = ['auth.User']
My function to follow a stuff:
def followUser(request, userId):
if not is_following_check(request.user, "user", userId):
to_follow = User.objects.get(id=userId)
follow(request.user, to_follow)
return HttpResponse("success")
else:
return HttpResponse("error")
def is_following_check(user, who, whoId):
if who == "user":
to_check = User.objects.get(id=whoId)
if is_following(user, to_check):
return True
else:
return False
else:
return False
My function to get the stream :
def userStream(userId):
user = User.objects.get(id=userId)
user_activities = model_stream(user)
return user_activities
And in the admin, I can see all the activities without any problem.
I found a "hack" to make it works in my dev environnement. In gfk.py, lines 70+:
for item in qs:
for gfk in gfk_fields:
if getattr(item, gfk.fk_field) != None:
ct_id_field = self.model._meta.get_field(gfk.ct_field).column
try:
setattr(item, gfk.name, data_map[(getattr(item, ct_id_field),
getattr(item, gfk.fk_field))])
except:
print "error gfk"
pass
return qs
im not sure that just printing the error and ignoring that item is a good idea since this is a classic failure case. maybe resetting the actstream db might help if you can afford to do it? im also noticing in your example that you are using model_stream but you should probably be using user_stream. also in followUser you do not check to see whether the user is logged in. this might have something to do with it but i am going to make this problematic corner case a bit more obvious in a future release. im sorry but i cannot be of much more help because i do not have your setup in front of me to see what's happening.
it's a weird error ive just recently run into. there's a problem with your project setup. here are some tips which should help
Try v0.4.2 which might help but theres not much else i can do.
When using model_stream(Model) in views I get this error :
Exception Type: KeyError Exception Value: (15L, u'1') Exception Location: site-packages/actstream/gfk.py in fetch_generic_relations, line 79
This Model works with follow() and unfollow()