Pharaoh Cleopatra Crack Code Activation Home → Pharaoh + Expansion pack Cleopatra for Mac OSX.. There Are Any Vpn Clients For Mac Rosetta Stone Italian Activation Code Crack Mackeeper How .Q: Django filter by one field that is a choice of a different field in a ForeignKey I'm a beginner using Django and I'm trying to filter by a different field for a different field in a ForeignKey. I have two models, a Building model and a Pedestrian model. My primary key is a foreign key to both of them. The problem I'm having is that when I try to query "select b.building from ped.Pedestrian as p where p.building_id = 3" I get the same set of buildings back that I get when I do "select * from ped.Pedestrian" I'm filtering by a different field in the building model (by accessing it as Building.ID in the Pedestrian model) but I'm not sure why this is happening. Any help is greatly appreciated. Building model class Building(models.Model): building_name = models.CharField(max_length=256) building_id = models.CharField(max_length=256) def __str__(self): return self.building_name Pedestrian model class Pedestrian(models.Model): building_id = models.ForeignKey(Building, on_delete=models.CASCADE) count = models.IntegerField() id = models.CharField(max_length=32, primary_key=True) def __str__(self): return self.id A: You need to specify the model you are querying on. In your case you want to use Pedestrian so you could do: Pedestrian.objects.filter(building__id=3) You could also do: Building.objects.get(pk=3) etc. Wednesday, March 30, 2008 Due to the severe electric power outages we've had here in the Ozarks the past few days (we lost electricity two days in a row), my Big Blog Show d0c515b9f4
Related links:
Comments