我正在尝试获取已售产品的总数,这是代码:
模型.py
class Ventas(models.Model):
codigoventa = models.CharField(max_length=7, unique=True)
codigocliente = models.ForeignKey('Clientes')
Fecha_registro = models.DateTimeField("Fecha de edicion", auto_now_add=True)
totalventa = models.DecimalField(max_digits=10, decimal_places = 2)
codigosucursal = models.ForeignKey('Sucursales')
totalventa = models.IntegerField()
def __unicode__(self):
return self.codigoventa
视图.py
def ventas_anio(request):
ventas = Ventas.objects.all().aggregate(total_payment=Sum('totalventa'))
return render_to_response('ventasanual.html',{'datos':ventas}, context_instance=RequestContext(request))
我无法使用此视图。