-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, ]
只有當我添加屬性對象這項工作。
這裏有什麼問題?講清楚。 – arulmr 2013-02-25 12:07:43
如果我添加'Apartament'和'Land'對象(現在它只在添加'Property'對象時才起作用),那麼如何創建StackInline? – user2096122 2013-02-25 12:10:05