単一の管理ページに表示したいモデルがいくつかあります。ここに私のモデルがあります:
class Server(models.Model):
type = models.CharField(max_length=44, choices=TYPES)
number = models.CharField(max_length=3)
environment = models.CharField(max_length=7, choices=ENVIRONMENTS)
location = models.CharField(max_length=3, choices=LOCATONS)
cpu = models.PositiveSmallIntegerField()
ram = models.PositiveIntegerField()
os = models.CharField(max_length=24, choices=OSs, default='CentOS 6.3')
eth0_ip = models.IPAddressField(unique=True)
eth0_mac = models.CharField(max_length=17, unique=True, null=True,
blank=True)
confluence_page = models.URLField(null=True, blank=True)
class Meta:
abstract = True
def __unicode__(self):
return "%s%s.%s" % (self.type, self.number, self.environment)
class Real(Server):
manufacturer = models.CharField(max_length=20, choices=MANUFACTURERS_REAL)
rack = models.CharField(max_length=6, null=True, blank=True)
rack_u = models.PositiveSmallIntegerField(null=True, blank=True)
serial_num = models.CharField(max_length=8, unique=True, null=True,
blank=True)
class Virtual(Server):
manufacturer = models.CharField(max_length=20,
choices=MANUFACTURERS_VIRTUAL)
host_id = models.ForeignKey(Real)
私が疑問に思っているのは、両方のデータベースからすべてのオブジェクトを表示できるようにする管理インターフェイスを作成/拡張/何でもできるかどうかです。たとえば、管理画面に移動してアプリ名をクリックすると、両方のデータベースの change_list が表示されます。特定のオブジェクト、たとえば Virtual を選択すると、仮想オブジェクトを作成または変更するための管理インターフェイスが表示されます。
明確でない場合はお知らせください。別の方法でより明確に説明できるように最善を尽くします。