title: How to validate child serializer that requires data from parent in django rest framework nested serializer?
body: <p>I am using <a href="https://github.com/beda-software/drf-writable-nested" rel="nofollow noreferrer">DRF Writable Nested</a>  to create writable nested serializer.</p>
  
  <p>I need to validate 'ItemDetail' but it requires 'product_id' which is present in the parent serializer i.e. 'InvoiceItem'.</p>
  
  <p>Models</p>
  
  <pre><code>class InvoiceItem(models.Model):
      product = models.ForeignKey(
          Product, on_delete=models.CASCADE, related_name="invoice_items"
      )
  
  
  class ItemDetail(models.Model):
      invoice_item = models.ForeignKey(
          InvoiceItem, on_delete=models.CASCADE, related_name="item_details"
      )
      size = models.ForeignKey(
          Size, on_delete=models.CASCADE, related_name="item_details"
      )
      quantity = models.PositiveIntegerField()
  </code></pre>
  
  <p>Serializers</p>
  
  <pre><code>class InvoiceItemSerializer(WritableNestedModelSerializer):
      product = ProductMiniSerializer(read_only=True)
      product_id = serializers.IntegerField(write_only=True)
      item_details = ItemDetailSerializer(many=True)
  
      class Meta:
          model = InvoiceItem
          fields = [
              "id",
              "product_id",
              "product",
              "item_details",
          ]
  
  
  class ItemDetailSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = ItemDetail
          fields = [
              "id",
              "size",
              "quantity",
          ]
  
      def validate(self, data):
          return item_detail_validate(self, data)
  </code></pre>
  
  <p>Validator</p>
  
  <pre><code>def item_detail_validate(self, data):
      # How to get product_id here so I can use it in a query
      return data
  </code></pre>