1👍
✅
you are looking for a many-to-one relationship
https://docs.djangoproject.com/en/1.8/topics/db/examples/many_to_one/
you already set the related_name to “predio_propietario+” and with the ‘+’ at the end this means there is no backwards relation to this model
there is you example:
queryset = Propietario.objects.filter(predio__nombre_predio__iexact=request.POST['nombre_predio'])
Extra:
class C(models.Model):
c_text = models.CharField(max_length=100)
class B(models.Model):
b_text = models.CharField(max_length=100)
class A(models.Model):
b = models.ForeignKey(B)
c = models.ForeignKey(C)
queryset will look like this:
queryset = A.objects.filter(b_btext__isexact="your b text", c_ctext__isexact="your c text")
Source:stackexchange.com