2013-01-23 5 views
2

하나의 관리 페이지에 여러 모델을 표시하고 싶습니다. 여기 내 모델입니다 :장고 관리자가 두 페이지를 하나의 페이지로 결합합니다.

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가 표시되고 특정 개체를 선택하면 가상이라고 말하고 관리자 인터페이스를 생성하거나 가상 개체를 변경합니다.

내가 명확하지 않은 경우 알려 주시면 설명을 더 분명하고 명확하게 설명해 드리겠습니다. 인스턴스에서

https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin

을 실제 서버의 자식이기 때문에 당신이 수 : 표시 할 상위 모델 유형에 공통의 외래 키가 있다면

답변

0

장고 관리자 인라인 당신을 도울 것입니다 인라인이있는 관리 페이지를 작성하여 관리자의 해당 서버에있는 모든 가상 오브젝트를보십시오.

관련 문제