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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:56:59+00:00 2026-06-01T09:56:59+00:00

Here is my models, class Age(models.Model): layer = models.CharField(max_length=50) order = models.PositiveIntegerField() … class

  • 0

Here is my models,

class Age(models.Model):
    layer = models.CharField(max_length=50)
    order = models.PositiveIntegerField()
    ...
class Course(models.Model):
    target_age = models.ManyToManyField('Age')
    ...

How can I get a course queryset including a specific age?
views:

request_courses = Course.objects.filter(target_age ...
  • 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-01T09:57:01+00:00Added an answer on June 1, 2026 at 9:57 am

    Your question is a little vague. First, have a read of the documentation on querying across relationships.

    If you want to get courses related to only those Age‘s with a particular field value:

    Course.objects.filter(target_age__FIELD=...)
    

    where FIELD is the field in your Age model you want to query against.

    Alternatively, if you have an Age object and you want to get all courses that are actually related to a particular Age object, you need:

    age = Age.objects.get(...)
    courses = Course.objects.filter(target_age=age)
    

    or if you want to get courses that are related to at least one of a number of possible Age‘s:

    ages = Age.objects.filter(...)
    courses = Course.objects.filter(target_age__id__in=ages.values_list('id'))
    

    EDIT

    The last example is using the in lookup

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

Sidebar

Related Questions

Here is a Django model I'm using. class Person(models.Model): surname = models.CharField(max_length=255, null=True, blank=True)
Here are my models: class Groups(models.Model): group_id = models.AutoField(primary_key=True) group_name = models.CharField(max_length=20,db_index=True) #Some other
Here some models: class UserProfile(models.Model): name = models.CharField(max_length=30) email = models.EmailField(unique=True, db_index=True) birthday =
Here is a simplified version of one of my models: class ImportRule(models.Model): feed =
Here's part of my Django app's models.py : class Person(models.Model): birth_year = WideYear(null=True, blank=True)
Okay so I have this mode: class Posts(db.Model): rand1 = db.FloatProperty() #other models here
I'm not very good with Django's form . Here is Order from models.py class
here is my model class gameUserTrophyInfo(models.Model): user = models.ForeignKey(userInfo) trophy = models.ForeignKey(gameTrophyInfo) date =
Here's a snippet from my application: class PortolioItem(models.Model): ... user = models.ForeignKey(User) contract =
I'm having trouble generating a nested model form. Here are my models: class Workout

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.