Garage.cars: object garage has a FK of cars
Person.carwishlst: object Person has FK of cars they would like.
In Django how to I achieve the following, loop?...
Get the total number of cars x the Person has which match the ones the Garage has.
Outcome: i.e. Grange has 4 cars you want
Hypothetical, but lets say Grange model has an FK cars = models.ManyToManyField(Cars)
Person also has a FK cars_wishlist = models.ManyToManyField(Cars)
Supposing that
Garage.cars
andPerson.carwishlist
are both lists and that the contained cars have a sensible__eq__
method:Assuming the
cars
andcarwishlst
are lists:You would do the following
That should do it.