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),
]
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.
Also by me
Django Messaging
For Django-based social platforms.
Django App for You
Django Paddle Subscriptions
For Django-based SaaS projects.
Django App for You
Django GDPR Cookie Consent
For Django websites that use cookies.
Django App for You