engel
unread,Dec 9, 2007, 8:33:37 AM12/9/07Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django russian
xочу просуммировать all_quantity из объектов quantity_numberbill c
таким же значением в handbookmodel.article:
class Sklad(models.Model):
all_quantity = models.IntegerField(u'Количество', null=True,
editable=False)
handbookmodel = models.ForeignKey(HandBookModel)
compbill = models.ForeignKey('CompBill', unique=True)
class CompBill(models.Model):
quantity_numberbill = models.IntegerField(u'Количество')
bill = models.ForeignKey('Bill', unique=True)
type_effects = models.CharField(u'Тип записи',max_length=1,
choices=TYPE_CHOICES)
написал так:
def save(self):
if self.compbill.type_effects == 'A':
self.all_quantity = sum(map(lambda x:
x.quantity_numberbill,self.compbill.all()))
return super(Sklad, self).save()
но как-то не очень выходит.