Count Records in Listing View
Posted
by 47
on Stack Overflow
See other posts from Stack Overflow
or by 47
Published on 2010-06-14T07:39:40Z
Indexed on
2010/06/14
7:42 UTC
Read the original article
Hit count: 147
I have these two models:
class CommonVehicle(models.Model):
year = models.ForeignKey(Year)
series = models.ForeignKey(Series)
engine = models.ForeignKey(Engine)
body_style = models.ForeignKey(BodyStyle)
...
class Vehicle(models.Model):
objects = VehicleManager()
stock_number = models.CharField(max_length=6, blank=False)
vin = models.CharField(max_length=17, blank=False)
common_vehicle = models.ForeignKey(CommonVehicle)
....
What I want to do is to have a count of how many times a given CommonVehicle
object is used in the Vehicle
class. So far my attempts are giving me one number, which is a total of all the records. How can I have the count being the total appearances for each CommonVehicle
© Stack Overflow or respective owner