
model.py
class MedtechProductCategory(models.Model): name = models.CharField(max_length=128, null=False, blank=False) type = models.CharField(choices=type_choices_for_tag, max_length=512) class Meta: db_table = 'medtech_product_category' class ProductsInfo(models.Model): deal_active = models.BooleanField(default=True) category = models.ManyToManyField(MedtechProductCategory, related_name='product_info_category') class Meta: db_table = 'products_info' def getTags(self): return self.category.values_list()
admin.py
class ProductsInfoAdmin(admin.ModelAdmin): filter_horizontal = ('category',) admin.site.register(ProductsInfo, ProductsInfoAdmin)
So, I want to show the name of the category field in the filter search and save them as objects when saving.
How to configure it to show the name of the manytomany field and save the saved objects of the manytomany field
source share