The problem I have is to pass the chained search of two models to the template at the sight, these two databases are linked by a custom_id as shown below:
Note: This is an example of the interaction of the original model, which is very long
model:
from django.db import models
class Model (models.Model):
custom_id = (max_length = 10)
data = models.CharField (max_length = 100)
Model1 class (models.Model):
models.IntegerField custom_id = (max_length = 10)
Model2 class (models.Model):
relation2 = models.OneToOneField (Model1)
class UserProfile (models.Model):
models.ForeignKey user = (User, unique = True)
relation1 = models.ManyToManyField (Model2)
This shows me all this custom_id User log in on the page
custom = Model1.objects.filter (model2__userprofile__user__username = user)
The question is how to sack all the data related to this custom_id?
in terminal shows me the data and the two interactions with this for:
for element in custom:
customid = str(elemento.custom_id)
data = Model.objects.filter(customid=customid)
but I just keep one in the data.
I solved it already.
Loads another variable to the template that contains this variable has to do a loop and contain my custom query:
query functions in the same manner as in queryset template.