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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:22:47+00:00 2026-05-26T04:22:47+00:00

How do I create a list_filter of Assigned Bankers on the Client model? class

  • 0

How do I create a list_filter of Assigned Bankers on the Client model?

class AssignedBanker(models.Model):
    client         = models.ForeignKey(Client)
    banker         = models.ForeignKey(User)
    # ...

class Client(models.Model):
    account_name        = models.CharField(max_length=100)
    # ...

class ClientAdmin( MyModelAdmin ):
    list_filter = [ ??? ]
  • 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-26T04:22:48+00:00Added an answer on May 26, 2026 at 4:22 am

    By writing a list class that inherits from SimpleListFilter:

    from django.utils.translation import ugettext_lazy as _
    from django.contrib.admin import SimpleListFilter, RelatedFieldListFilter
    
    class AssignedBankerListFilter(SimpleListFilter):
        title = _('assignment')
        parameter_name = 'assignment'
    
        def lookups(self, request, model_admin):
           return AssignedBanker.objects.values_list('banker', 'banker__first_name',).distinct().order_by('banker__first_name')
    
        def queryset(self, request, queryset):
            if not self.value():
                return queryset
            assigned = AssignedBanker.objects.filter(banker=self.value())
            clients = [p.client.id for p in assigned]
            return queryset.filter(id__in=clients)
    
    class ClientAdmin( MyModelAdmin ):
        list_filter = [AssignedBankerListFilter, ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

if I write something like class Chip(models.Model): name = models.CharField(max_length=16) shortname = models.CharField(primary_key=True, unique=True,
Here are the model definitions: class ItemBrand(models.Model): name = models.CharField(max_length = 30, unique =
I have the following models: class Tag(models.Model): name = models.CharField(max_length=20) class Entry(models.Model): title =
I'm trying to create a multilevel search to allow user to refine the same
Hi Stackoverflow people, in my current project, I have the following model structure: class
I am using the following css to create list items with a chckerboard background
I want to create a list of columns in SQL Server 2005 that have
I want to create a list of integers from 1 to n . I
I want to create a list of methods to execute. Each method has the
I want to create a List of KeyValuePair s in a managed C++ project.

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.