我有这两个模型;
class Point(models.Model):
point = models.IntegerField()
description = models.CharField("Action", max_length=128)
class PointLog(models.Model):
user = models.ForeignKey('users.User', verbose_name ="Related User")
point = models.ForeignKey(Point)
date = models.DateTimeField(default = datetime.datetime.now())
Point
对象是静态的。我的意思是它们不会动态变化,它显示了哪个动作带来了多少分。PointLog 对象显示用户的操作。一个用户可以完成多个相同的操作。
我想PointLog
根据用户操作对对象进行分组并总结每个不同操作的点
帮助 :)
采样点对象;
description point
-----------------------
make comment 5
add photo 20
add video 50
示例 PointLog 对象;
User point date
------------------------------
user1 make comment ....
user1 make comment ....
user1 add photo ....
user1 add photo ....
user1 add photo ....
user1 add photo ....
user1 add video ....
user1 add video ....
user1 add video ....
样品结果;
user1s action;
make comment 10 points gained
add photo 80 points gained
add video 150 points gained