Skip to main content

Allow foreign key attributes in list_display with '__'

Project description

Allow foreign key attributes in Django admin change list list_display with ‘__’

This is based on DjangoSnippet 2996 which was made by Kpacn.


  1. This library is on PyPI so you can install it with:

    pip install django-related-admin

or from github:

pip install git+
  1. Add “related_admin” to your INSTALLED_APPS setting like this:


Note: Django-related-admin changes change_list.html template to disable white-space: nowrap; css class on admin headers to allow long (posibly related) header names to wrap. If you want this behaviour, add the app before django.contrib.admin, otherwise after.


Just use it instead of model.Admin:

from related_admin import RelatedFieldAdmin
from related_admin import getter_for_related_field

class FooAdmin(RelatedFieldAdmin):
    # these fields will work automatically (and boolean fields will display an icon):
    list_display = ('address__phone','address__country__country_code','address__foo')

    # ... but you can also define them manually if you need to override short_description or boolean parameter:
    address__foo = getter_for_related_field('address__foo', short_description='Custom Name', boolean=True)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-related-admin-1.0.1.tar.gz (11.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page