I have a model that looks like this:
class ParentObject(models.Model):
...
services = models.ManyToManyField(Service)
class ChildObject(models.Model):
parent = models.ForeignKey(ParentObject)
services = models.ManyToManyField(Service)
class Service(models.Model):
name = ...
description = ...
So, in summary, an object has a list of Services attached and a child objects has to have other Services attached.
In size, each Parent has a list of 50-60 Services and each Child (5 per Parent) has a list of 30-40 Services. In django-admin (using grappelli btw) I have set Child to inline.
The problem is that the page in admin loads very hard (3-5 seconds) because Django Admin executes about 1200 queries (to get the Service each time - sometimes multiple times) to show me the information to edit.
Do you know any tips/tricks to optimize this?
Thank you in advance.