L
L
Leonid2020-02-24 13:26:14
Django
Leonid, 2020-02-24 13:26:14

How to restrict selection in bound model in admin.TabularInline?

There are 4 models:

class Prop(models.Model):
   "" Свойства
    name = models.CharField()

class PropertyVariant(models.Model):
    """Служит для задания значений  Свойств"""
    property_product = models.ForeignKey(Prop)

class PropertyProduct(models.Model):
    """Справочник Свойство (товара)"""
    product = models.ForeignKey(Product, verbose_name=_("Товар"), on_delete=models.CASCADE, blank=True, null=True)
    prop = models.OneToOneField(Prop, verbose_name=_("Свойство"), on_delete=models.CASCADE)
    value = models.OneToOneField(PropertyVariant, verbose_name=_("Значение"), on_delete=mode


and the product itself:

class Product(models.Model):
    """Модель описания товара"""


in the admin panel, I make the PropertyProductAdmin as TabularInline and display it in the products:

inlines = [PropertyProductAdmin]

the essence of the question is this - in the PropertyVariant field it allows you to select all the entered values, but you need to select by the owner - the Prop model.
Tell me how to do it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question