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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:32:25+00:00 2026-06-15T08:32:25+00:00

I have models A and B, where B has a FK to A. I

  • 0

I have models A and B, where B has a FK to A.

I use django 1.3 and I need two django admin filters:

1) a.b_set.exists() # (True/False)

2) not a.b_set.filter(some_condition=False).exists() # (True/False)

How can I achieve that? Sadly, I couldn’t find any solutions by googling.

  • 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-15T08:32:26+00:00Added an answer on June 15, 2026 at 8:32 am

    You need to read this: Custom Filter in Django Admin on Django 1.3 or below

    This is my first attempt without any testing, but you should see more or less how its done –

    from django.db import models
    from django.contrib.admin.filterspecs import FilterSpec, ChoicesFilterSpec
    from django.utils.encoding import smart_unicode
    from django.utils.translation import ugettext as _
    
    class BNullSetFilterSpec(FilterSpec):
    
        def __init__(self, f, request, params, model, model_admin):
            super(BSetFilterSpec, self).__init__(f, request, params, model, model_admin)
    
            self.links = (
                ('Yes', {'b__isnull': False}),
                ('No', {}))
    
        def title(self):
            return _('B Set')
    
    # registering the filter
    FilterSpec.filter_specs.insert(0, (lambda f: getattr(f, 'empty_bset', False), BNullSetFilterSpec))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Models, Programme and Event, a programme has many events. I need
I have two models in Django: groups and entries. Groups has a many-to-many field
i have two models: class Category has many :jobs end class Job belongs_to :category
I have two models class Employer(models.Model): name = models.CharField(max_length=300, blank=False) id = models.IntegerField() status
I have Django models setup in the following manner: model A has a one-to-many
I am trying to manage the admin console. I have two models, a venue
I have created a model which has foreign key to the django.contrib.auth.models User model.
I have a django model in use on a production application and I need
I have an existing Django project that has several models using concrete inheritance of
I have a database, financials that has models created in django. In addition, it

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.