1

I am trying to open django admin for the following models..

class FirstModel(models.Model):
  name = models.CharField(max_length=100)

class SecondModel(models.Model):
  name = models.CharField(max_length=100)
  firstModel = models.ForeignKey(FirstModel, related_name='secondList')

class ThirdModel(models.Model):
  name = models.CharField(max_length=100)
  secondModel = models.ForeignKey(SecondModel, related_name='thirdList')

I am trying to create an admin.py for the following models as follows..

class ThirdModelInline(admin.TabularInline):
  model = ThirdModel
  extra = 1

class SecondModelInline(admin.StackedInline):
  model = SecondModel
  inlines = [ThirdModelInline]

class FirstModelAdmin(admin.ModelAdmin):
  inlines = [SecondModelInline]

admin.site.register(FirstModel, FirstModelAdmin)

I want to be able to edit the SecondModel and ThirdModel as a recursive relation inside FirstModel. But this is not working. I tried to follow this link : [Model with recursive self relation in Django's admin

[1]: Model with recursive self relation in Django's admin. Any help would be appreciated. Thanks!!

Community
  • 1
  • 1
Arpit Goel
  • 163
  • 1
  • 16

2 Answers2

1

Found a very good library after some websearch. Might help someone else..

https://github.com/s-block/django-nested-inline

Arpit Goel
  • 163
  • 1
  • 16
0

django-nested-inline isn't (yet?) supported on latest django releases.

But you could consider using django-nested-admin that is almost the same.

vmonteco
  • 14,136
  • 15
  • 55
  • 86