MerMer wrote: > I must be making some rookie mistake, but I can't work out why its not > working. The code fails to return anything for the line p_qs= > Promotion.objects.filter(id=promotion_id) and therefore the index on > the next line is out of bounds. > > def update_review_average(sender,instance,signal,*args,**kwargs): > """ > updates the average for the review on promotions any time that > a review is updated, or created. > > """ > promotion_id = instance.promotion > qs = Review.objects.filter(promotion = promotion_id)
This line makes me think that promotion_id contains a Promotion instance, rather than an ID. Is Review.promotion a ForeignKey to Promotion? If so, you can change these lines: > # save average to the relevant Promotion > p_qs = Promotion.objects.filter(id=promotion_id,) > p=p_qs[0] > p.av_rating = average > p.save() to: promotion_id.av_rating = average promotion_id.save() (Although you might consider renaming the "promotion_id" variable for clarity.) -Zak --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---