我有几个预订Appointment
的Customer
。每个Appointment
只有一个客户,尽管一个客户可以预订在不同时间发生的多个约会。
class Customer(model.Model):
def __unicode__(self):
return u'%s' % (self.name,)
name = models.CharField(max_length=30)
# and about ten other fields I'd like to see from the admin view.
class Appointment(models.Model):
datetime = models.DateTimeField()
customer = models.ForeignKey("Customer")
class Meta:
ordering = ('datetime',)
现在,当管理员通过查看管理员中的约会(按时间排序)来浏览日程时,有时他们希望查看有关具有特定约会的客户的信息。现在,他们必须记住客户的名字,从约会导航到客户管理页面,找到记住的客户,然后才能浏览他们的信息。
理想情况下,像管理员内联这样的东西会很棒。然而,我似乎只能在Appointment
管理页面上创建一个CustomerInline
,如果Customer
有一个ForeignKey("Appointment")
的话。(Django特别给了我一个错误,说Customer
没有到Appointment
的ForeignKey )。有没有人知道类似的功能,但是当Appointment
有一个ForeignKey('Customer')
时
注意:我简化了模型;除了name (一些自由文本)之外,实际的Customer字段目前还有大约10个字段,因此将所有信息放在__unicode__
中是不切实际的。
https://stackoverflow.com/questions/6419248
复制相似问题