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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:39:51+00:00 2026-06-08T07:39:51+00:00

I have two models that are linked by another model through a many to

  • 0

I have two models that are linked by another model through a many to many relationship.

Here’s the models themselves

class Posts(models.Model):
    id = models.CharField(max_length=108, primary_key=True)
    tags = models.ManyToManyField('Tags', through='PostTags')


class Tags(models.Model):
    id = models.CharField(max_length=108, primary_key=True)
    posts = models.ManyToManyField('Posts', through='PostTags')

class PostTags(models.Model):
    id = models.CharField(max_length=108, primary_key=True)
    deleted = models.IntegerField()
    post_id = models.ForeignKey('Posts', db_column='post_field')
    tag_id = models.ForeignKey('Tags', db_column='tag_field')

And the tastypie resources

class PostsResource(ModelResource):
    tags = fields.ToManyField('django_app.api.TagsResource', 'tags', null=True)
    class Meta:
        queryset = Posts.objects.filter(deleted=0)
        resource_name = 'posts'

class TagsResource(ModelResource):
    posts = fields.ToManyField('django_app.api.PostsResource', 'posts', null=True)
    class Meta:
        queryset = Tags.objects.filter(deleted=0)
        resource_name = 'tags'

On the posttags table there is a deleted flag, is it possible to only return linked results when the deleted flag in PostTags is 0?

I have tried this filter attribute in tastypie but it only seems to care about the flag in the linked table(ie tags or posts) not the actual table doing the linking.

  • 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-08T07:39:53+00:00Added an answer on June 8, 2026 at 7:39 am

    You can filter fields using lambda bundle attribute showing table name and field name.

    tags = fields.ToManyField('django_app.api.TagsResource', attribute=lambda bundle: bundle.obj.tags.filter(tags__deleted=0))
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models Category and Entry . There is another model ExtEntry that
I have three models linked by foreign keys: class One(models.Model): ... class Two(models.Model): one
I have two models: class Studio(models.Model): name = models.CharField(Studio, max_length=30, unique=True) class Film(models.Model): studio
I have a two models that are similar, but not exactly the same. Here's
I have two models -- User and Entry -- that are related through a
I have two models in Django linked together by ManyToMany relation like this: class
I have two models as x and y, such that: y.rb: class y <
I have two models that two relationships between them class Tracking include Mongoid::Document belongs_to
I have two models that I currently have as STI. class Event class BlockedTime
I have two models that are associated with each other. Customer has_one :primary_contact And

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.