A admin.StackedInline class uses a Model class, and the Model class has a foreign key (models.ForeignKey). This foreign key is generating too many SQL queries, as it tries to make a select list containing all items in the referred-to table (ProductTemplate).
Is there a way to restrict the foreign key to only list one item, instead of all items in the referred-to table?
Any other suggestions will also be highly appreciated. Let me know if you need more details.
Partial source code:
In file admin.py: ... class TransactionAttributeInlineAttribute(admin.StackedInline): model = models.TransactionAttribute verbose_name = 'Transaction Link' verbose_name_plural = 'Product Links' class MyAttributeAdmin(admin.ModelAdmin): inlines = [TransactionAttributeInlineAttribute] list_display = ['name','datatype','required'] ... In file models.py: ... class TransactionAttribute(models.Model): product_template = models.ForeignKey(ProductTemplate) ...