I have multiple models like this:
class Model1(models.Model):
user = models.ForeignKey(User)
model1_filed1 = models.CharField()
class Model2(models.Model):
user = models.ForeignKey(User)
model2_filed1 = models.CharField()
....
As you can see all the models have a filed user = models.ForeignKey(User) on each model so when I save my model data I know what user saved it.
On my project I need to:
-
Do a search on model1_filed1 (Moldel1). Something like find all the records from Model1 that have model1_filed1 containing the string “foo”.
-
Once I find Model1 records containing the tring “foo” on the mode1_filed1 join all the records from Model2 that have the same user id as the Model1 records just found.
Any ides?
1 Answer