How to show related objects in Django/Admin?

You can use “Inlines” to visualize and edit Things of a certain Category in the admin detail for that category:

In the admin.py file, create an Inline object for Thing (ThingInline) and modify your CategoryAdmin class to have an inline of type ThingInline like this:

...
class ThingInline(admin.TabularInline):
    model = Thing

class CategoryAdmin(admin.ModelAdmin):
    inlines = [
        ThingInline,
    ]
...

For further details, this is the docs for admin inlines: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)