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 8855367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:07:09+00:00 2026-06-14T14:07:09+00:00

Suppose, there is a list strings = [‘a’,’b’,’c’] And There are two model class

  • 0

Suppose, there is a list

strings = ['a','b','c']

And There are two model

class theModel:
   theString = models.charField()

Class superModel:
   hasClass = models.ForeignKey(theModel)

Is there any way to filter superModel by ‘theString’ with list?

for example this can be one way ( but is there any better way? without for loop )

tuple = []
for string in strings
   tuple.append ( theModel.objects.filter(theString = string) )

result = []
for theModel in tuple 
   result.append ( superModel.objects.filter(hasClass = theModel ) )

return result
  • 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-14T14:07:10+00:00Added an answer on June 14, 2026 at 2:07 pm

    You can do this:

    theModel.objects.filter(theString__in=[1,4,7])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose there's a top-secret list (inherits its permissions from its parent) that contains records
Suppose there are two lists a = {a1, a2, a3} and b = {b1,
Suppose I have a list of strings where each string is exactly 4 characters
Suppose I have the following list: var strings = new List<string>(); strings.Add(1); strings.Add(12.456); strings.Add(Foobar);
Suppose there's a list of arguments stored somehow, in a array for example. Given
I have two classes university and department, suppose there is one to many relationship
Suppose you have a list of MyObject like this: public class MyObject { public
Suppose there is a list that is input from the console using <STDIN> @string
suppose you have an big unsorted List<MyClass> of public class MyClass { public Guid
Suppose there is a script sth.py When i logged with 'root' account. type :

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.