这些是我的模特:
class Company(models.Model):
name = models.CharField(
max_length=100,
verbose_name = _(u'Nome'),
)
contacts = models.ManyToManyField('Person', through='CompanyContact', verbose_name = _(u'Contatos'))
class Person(models.Model):
name = models.CharField(
max_length=200,
verbose_name = _(u'Nome'),
)
position = models.CharField(
max_length=100,
verbose_name = _(u'Cargo'),
)
email = models.EmailField(
max_length=100,
verbose_name = _(u'Email'),
unique=True,
)
employer = models.ForeignKey('Company', verbose_name=_(u'Empresa'))
addresses = models.ManyToManyField('Address', verbose_name = _(u'Endereços'))
phones = models.ManyToManyField('Phone', verbose_name = _(u'Telefones'))
在公司管理员中:
class CompanyAdmin(admin.ModelAdmin):
....
inlines = (ContactInline,)
...
class ContactInline(admin.TabularInline):
model = CompanyContact
extra = 0
verbose_name = u'Representante'
verbose_name_plural = u'Representantes'
所有这些配置都在公司管理员中生成:
没关系,但我怎样才能在admin内联中添加整个联系人管理员,而不仅仅是名称属性(因为我在个人模型中定义了它的名称)?我想要做的是在管理员内联中按名称保持联系人选择,但并排显示另一个属性。例如:
在admin inline中:
提前致谢!