About Admin List Filter with Options Limited to Existing Relations

Django provides an ability to show related items in the list filter only if they are connected to this model instances:

from django.contrib import admin
from django.contrib.admin import RelatedOnlyFieldListFilter
from .models import Post

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_filter = [
        ("categories", RelatedOnlyFieldListFilter),
    ]

Programming Development Django 6.x Django 5.2 Django 4.2

Django/Python Consulting

If you have a specific Django challenge or integration you'd like to solve, I'd be happy to help. Book a free 30-minute call to discuss your project, see if we're a good fit, and explore the best approach for your needs. After the call, you'll receive a tailored cost estimate based on what we discuss.