are there any conditions where signals are sent twice?
i have these models (among others)

#sales.models.py
class Sale(models.Model):
    customer = models.ForeignKey(Customer)
    stock = models.ForeignKey(Stock)
    quantity = models.IntegerField()
    price = models.DecimalField(max_digits=10,decimal_places=2)
    date_of_sale = models.DateField()
    #other models fields

#summary.models.py
class Summary(models.Model):
    stock = models.ForeignKey(Stock)
    sales = models.IntegerField()
    date = models.DateField()
    #other model fields

def update_on_sale(instance):
    summary =
Summary.objects.get(stock=instance.stock,date=instance.date_of_sale)
    summary.sales += instance.quantity
    summary.save()

dispatcher.connect(update_on_sale,signal=signals.post_save,sender=Sale)

I am using the admin site.
i have tests which pass, however when i add a new sale via the admin site,
i noticed that the summary.sales will be twice the sale.quantity
e.g.
after i add a sale with quantity = 5, the summary.sale is incremented by 10
instead of 5

I also use the post_save signal of the Sale model to update
Customer.account_balance
Is there any condition that will make the signal be sent twice?

-- 
Bayo
Qrapht Software Dev. Co.
http://boyombo.blogspot.com
http://www.qrapht.com

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to