1👍
✅
The value for fk_name
has to be the name of the class (lower-case), prefixed with either "from_"
or "to_"
, depending on your needs. So in your case, it has to be either fk_name='from_category'
or fk_name='to_category'
:
class ChildrensInline(admin.TabularInline):
model = Category.children_ids.through
fk_name='from_category' # or: 'to_category'
Generally, a quick way to figure such things out is to (transiently) place a simple print(model.__dict__)
pretty much anywhere in your code, here e.g. right after the second line. Then all fields of model
will be shown in the console output.
Source:stackexchange.com