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

  • Home
  • SEARCH
  • 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 429463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:46:40+00:00 2026-05-12T19:46:40+00:00

I have to work with a queryset, that is already filtered, eg. qs =

  • 0

I have to work with a queryset, that is already filtered, eg. qs = queryset.filter(language=’de’) but in some further operation i need to undo some of the already applied filtering, eg not to take only the rows with language=’de’ but entries in all languages. Is there a way to apply filter again and have the new parameters connected to the already existing ones using OR not add, eg. if the queryset is already filtered for language=’de’ and i would be able to connect an ‘OR language=’en’ to that, it would give me what i’m looking for!
Thanks!

  • 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-05-12T19:46:41+00:00Added an answer on May 12, 2026 at 7:46 pm

    I don’t believe it is possible to do what you are asking.

    The way you do ORs in django is like this:

    Model.objects.filter(Q(question__startswith='Who') | Q(question__startswith='What'))
    

    so if you actually wanted to do this:

    Model.objects.filter(Q(language='de') | Q(language='en'))
    

    you would need to put them both in the same filter() call so you wouldn’t be able to add the other or clause in a later filter() call.

    I think the reason you may be trying to do this would be that you are concerned about hitting the database again but the only way to get accurate results would be to hit the database again.

    If you are simply concerned about producing clean, DRY code, you can put all the filters that are common to both queries at the top and then “fork” that query set later, like this:

    shared_qs = Model.objects.filter(active=True)
    german_entries = shared_qs.filter(language='de')
    german_and_english = shared_qs.filter(Q(language='de') | Q(language='en'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a C# programmer but I have to work with some VB.Net code
I have a table that stores various clients I have done work for, separated
I have a Portable Bridge Notation formatted-file that I have to work with. I
I was just told that I might have to work on a project where
I sometimes have the need to make sure some instances are excluded from a
I have this path in my urls.py: archive_index_dict = { 'queryset': News.objects.filter(show=True), 'date_field': 'date',
The commandlink link2 does not have work after an ajax call is made to
I have to work with strings which may contain Lat/Long data, like this: $query
Do I have to work with an ActionListener or AbstractAction ? EDITED BASED ON
What options do I have to work around disabled cookies for session management?

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.