How to request object.id in form clean data funtion
<p>Have a models:</p>

<pre><code>class Product(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    name = models.CharField(max_length=50)
    variation_1 = models.BooleanField(default=True)
    variation_2 = models.BooleanField(default=True)
    variation_3 = models.BooleanField(default=True)


class Order(models.Model):
    buyer = models.ForeignKey(User, related_name='buyer')
    product = models.ForeignKey(Product)
    variations_select = models.CharField(max_length=50, choices=VARIATIONS)
</code></pre>

<p><strong>in forms.py</strong></p>

<pre><code>class OrderForm(forms.ModelForm):
    variations_select = forms.ChoiceField(choices=VARIATIONS)

    class Meta:
        model = Order
        fields = [
            'variations_select'
        ]
</code></pre>

<p>i need to create a clean function that will check if <code>variation_1</code> or <code>variation_2</code> or <code>variation_3</code> are availiable in <code>Product</code>. For this a need request <code>Product.id</code> to  <code>def clean_variations_select(self):</code> How to do this?</p>

<pre><code>def clean_variations_select(self):
    product = Product.object.get(id = product.id)
    variations_select = self.cleaned_data.get("variations_select")
        if variations_select == "Variation_1" and product.variation_1 == False:
                raise forms.ValidationError("variation_1 was sold already")
        else:
                return variations_select
</code></pre>

<p><code>product = Product.object.get(id = product.id)</code> - don't work cause Order isn't created to database yet(but in rendering view link to new order creation i have that ../product.id/new_order). </p>