In a django app, I have a HouseHold
model, with a children
ManytoMany Foreign key to a Child
Model.
In the admin, I m showing the linked Child
instances in an inline, following closely django docs on the subject :
class FamilyInline(admin.TabularInline):
model = HouseHold.children.through
class HouseHoldAdmin(admin.ModelAdmin):
inlines = [ FamilyInline, ]
exclude = ( children ,)
I works well but shows a HTML select widget, containing all children from every households (which is very long : 8000+ items)
我试图将这一表格添加到家庭信息:
class ChildForm(forms.ModelForm):
class Meta:
model = Child
fields = ( name , school )
class FamilyInline(admin.TabularInline):
form = ChildForm
model = HouseHold.children.through
But this throws an error :
FieldError at /admin/myapp/household/820126/
Unknown field(s) (name, school) specified for HouseHold_children
我只想向每个孩子展示一些田地(第一名称、最后名称、学校......)而不是这一选择的植被。 是否可能?