我有以下型號:間接直列
class UserProfile(models.Model):
user = models.OneToOneField(User)
class Property(models.Model):
user = models.ForeignKey(User)
我想創建一個TabularInline
顯示連接到特定UserProfile
其Django管理頁面中的所有屬性。這裏的問題是,當然,物業沒有一個ForeignKey
直接UserProfile
,所以我不能簡單地寫
class PropertyTabularInline(admin.TabularInline):
model = Property
class UserProfileAdmin(admin.ModelAdmin):
inlines = (PropertyTabularInline,)
如何我容易嗎我想要什麼?
這不是我想要的,但是 - 我想要在配置文件管理頁面上顯示內聯,而不是用戶管理頁面。 – haroba