【发布时间】:2020-07-19 19:23:11
【问题描述】:
我有两个通过ManyToManyField 连接的模型。我没有手动指定through 表,所以Django 隐式创建了一个。
我现在可以以某种方式自定义 through 表,特别是更改其 ___str___ 函数吗?
基本上,我正在尝试覆盖 TabularInline 管理类使用的“行标题”,就像在这些问题中一样:
- Remove or edit object name in admin.TabularInline
- How to override the str method when rendering StackedInline field?
- https://groups.google.com/d/topic/django-users/d0QPIAklSug
但我想避免自定义模板或显式创建“关系表”,因为现在它由 Django 管理。
【问题讨论】: