-1
Apartament
및 Land
개체도 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 부동산의 객체를 추가 할 경우에만 작동합니다.
여기서 질문은 무엇입니까? 확실히 해. – arulmr
'Apart'과'Land' 객체를 추가하면 StackInline을 만드는 방법 (현재는'Property' 객체를 추가 할 때만 작동합니다) – user2096122