Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8149151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:47:28+00:00 2026-06-06T14:47:28+00:00

The problem I have is to pass the chained search of two models to

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:47:30+00:00Added an answer on June 6, 2026 at 2:47 pm

    I solved it already.

    Loads another variable to the template that contains this variable has to do a loop and contain my custom query:

    from itertools import *
    
    for element in custom:
        result = # operation
        query = chain (query, [result])
    

    query functions in the same manner as in queryset template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have two problem in this Case : I want to pass a JSON
The problem: I have a mutable.Map[Integer, String], I want to pass it to two
I have this little problem, that I cannot figure out which arguments to pass
Problem: I have two array where one produce a category and the second produce
Hi i have problem with a class i want to pass in an intent
i have problem to pass data from view to controller , i have view
I have to pass two strings to a thread, which will return an array
I have problem that I need to create timer but I want to pass
so i have this problem where i have something to pass back to the
I have complex model with double values...I have problem with pass them into object.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.