How to do nested inlines in Django?
I have models:
from django.db import models
class Request(models.Model):
class Method(models.TextChoices):
POST = "POST", "POST"
GET = "GET", "GET"
PUT = "PUT", "PUT"
DELETE = "DELETE", "DELETE"
method = models.CharField(
max_length=10,
choices=Method,
default=Method.GET,
)
url = models.TextField()
class Response(models.Model):
request = models.ForeignKey(Request, on_delete=models.CASCADE, related_name="responses")
body = models.TextField(null=True)
class RequestParam(models.Model):
key = models.TextField()
value = models.TextField()
response = models.ForeignKey(Response, on_delete=models.CASCADE, related_name="params")
And I'd like to display then all nested
request
response1
params
response2
params
...
How can I do it?
Django admin does not support nesting inlines more than one level deep. Use the third-party package django-nested-admin.