I have two django models (simplified):
class Product(models.Model): name = models.TextField() price = models.IntegerField() class Invoice(models.Model): company = models.TextField() customer = models.TextField() products = models.ManyToManyField(Product)
I would like to see relevant products as a beautiful table (of product fields) on the Invoice page in admin and be able to link to individual relevant product pages.
My first thought was to use the built-in admin, but django used a selection window widget for each related product. This is not related to the Product pages, and since I have thousands of products, and each checkbox independently loads all the product names, it quickly becomes unreasonably slow.
So, I turned to using ModelAdmin.filter_horizontal, as suggested here , which used one instance of another widget, where you have a list of all products and another list of related products, and you can add / remove products in a later one from the previous ones. This solved the slowness, but it still does not display the corresponding Product fields, and it is not related.
So what should I do? change settings? to override ModelForms? I googled around and couldn't find any example of such code ...
source share