2013-02-25 2 views
-1

ApartamentLand 개체도 Contact 양식과 Photo 양식을 추가하면 표시 방법?상속 모델 및 외래 키

class Property(models.Model): 
    title = models.CharField(max_length=255) 
    slug = models.SlugField() 
    desc = models.TextField() 

class Apartament(Property): 
    bedrooms = models.IntegerField() 
    levels = models.IntegerField() 
    something = models.CharField(max_length=255) 

class Land(Property): 
    something = models.CharField(max_length=255) 

class Contact(models.Model): 
    name = models.CharField(max_length=100) 
    phone = models.CharField(max_length=20) 
    property = models.ForeignKey(Property) 

class Photo(models.Model): 
    photo = models.ImageField(upload_to='images') 
    property = models.ForeignKey(Property) 

admin.py :

class PhotoInline(admin.StackedInline): 
    model = Photo 
    can_delete = True 

class ContactInline(admin.StackedInline): 
    model = Contact 
    can_delete = True 

class PropertyAdmin(admin.ModelAdmin): 
    inlines = [PhotoInline, ContactInline, ] 

I 부동산의 객체를 추가 할 경우에만 작동합니다.

+2

여기서 질문은 무엇입니까? 확실히 해. – arulmr

+0

'Apart'과'Land' 객체를 추가하면 StackInline을 만드는 방법 (현재는'Property' 객체를 추가 할 때만 작동합니다) – user2096122

답변

1

관리자 (인라인)가 대칭이 아니므로 필요한 인라인을 포함하여 해당 모델에 대한 관리 클래스를 등록해야합니다.