我想将一些datagridview列的行加在一起,并在底部添加一行,其中包含每列的总计。
我已经找到了计算每个datagridview列的总数的方法,但我无法以编程方式向数据网格视图添加新行。
以下是我的代码段
from django.db import models
import numpy as np
class Product(models.Model):
name = models.CharField(max_length=200)
def average_rating(self):
all_ratings = map(lambda x: x.rating, self.review_set.all())
return np.mean(all_ratings)
def __unicode__(self):
return self.name
class Review(models.Model):
RATING_CHOICES = (
(1, '1'),
(2, '2'),
(3, '3'),
(4, '4'),
(5, '5'),
)
product = models.ForeignKey(Product)
pub_date = models.DateTimeField('date published')
user_name = models.CharField(max_length=100)
comment = models.CharField(max_length=200)
rating = models.IntegerField(choices=RATING_CHOICES)