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!!