django - Nested TabularInline model in DjangoAdmin -
i have 3 models: firstentity
, secondentity
, thirdentity
. have used tubularinline
include secondentity
in firstentity
form, cannot figure out best way include thirdentity
part of secondentity
. assume method nested inline?
so construction following: firstentity <- secondentity <- thirdentity
here sample code:
# models class firstentity(models.model): name = model.charfield() class secondentity(models.model): name = model.charfield() firstentity = models.foreignkey(firstentity) class thirdentity(models.model): name = model.charfield() secondentity = models.foreignkey(secondentity) # admin class secondentityinline(admin.tabularinline): model = secondentity class firstentityadmin(admin.modeladmin): inlines = ( secondentityinline, )
as sidenote utilize django 1.7.2
i solve problem using manytomany field instead, have hard time figuring out whether should avoid or utilize m2m fields.
have @ django-nested-inline
https://github.com/s-block/django-nested-inline
https://pypi.python.org/pypi/django-nested-inline/0.3.3
django django-models django-admin
No comments:
Post a Comment