title: How to Pass the request to another Serializer for Validation
body: <p>I have two tables in my database to insert a product record. I am storing the product info in the <code>Product</code> table and the rest of the info like Pirce, Quantity etc storing to another table which is <code>ProductStock</code>.</p>
  <p>I am planning to send the data to a server something like this.</p>
  <pre><code>{
      &quot;name&quot;:'product name',
      &quot;brand&quot;:&quot;socialcodia&quot;
      &quot;product_stock&quot;:{
          &quot;price&quot;:&quot;100&quot;,
          &quot;quantity&quot;:&quot;50&quot;
      }
  }
  </code></pre>
  <p>I am easily able to validate the product info from <code>ProductSerializer</code>. But I don't have any perfect idea to validate the <code>ProductStockSerializer</code> data.</p>
  <p><strong>ProductSerializer</strong></p>
  <pre><code>from rest_framework import serializers
  from .models import Product
  from .models import Medical
  
  class ProductSerializer(serializers.ModelSerializer):
      
      medical = serializers.CharField(read_only=True)
      id = serializers.CharField(read_only=True)
      is_visible = serializers.CharField(read_only=True,default=True)
  
      class Meta:
          model = Product
          fields = ['id','medical','category','item','brand','is_visible']
  
      def validate(self, attrs):
          request = self.context.get('request')
          attrs['medical'] = Medical.objects.get(pk=request.info.get('medical'))
          return attrs
  </code></pre>
  <p>Here I want to validate the <code>product_stock</code> info as well. cuz it's coming with a single request. So is there any way that i can import the <code>ProductStockSerializer</code> into <code>ProductSerializer</code> and pass the data to that serializer. then validate it.</p>
  <p><strong>ProductStockSerializer</strong></p>
  <pre><code>from rest_framework import serializers
  from .models import ProductStock
  from medical.models import Medical
  
  class ProductStockSerializer(serializers.ModelSerializer):
  
      medical = serializers.CharField(read_only=True)
      
      class Meta:
          model = ProductStock
          fields = ['medical','distributer','product','variant','batch','purchase_price','price','quantity','location','low_stock','expire_date']
  
  
      def validate(self, attrs):
          
          attrs['medical'] = Medical.objects.get(self.context.get('request').info.get('medical'))
          batch = attrs.get('batch')
          purchase_price = attrs.get('purchase_price')
          price = attrs.get('price'),
          if len(batch) &lt; 3 or len(batch)  &gt; 30:
              raise serializers.ValidationError(&quot;Invalid Batch Number&quot;)
  
          if type(purchase_price) != int or type(purchase_price) != float:
              raise serializers.ValidationError(&quot;Invalid Purchase Price&quot;)
  
          if type(price) != int or type(price) != float:
              raise serializers.ValidationError(&quot;Invalid Price&quot;)
  
          return attrs;
  </code></pre>
  <p><strong>ProductViewSet</strong></p>
  <pre><code>class ProductViewSet(ModelViewSet):
      queryset = Product.objects.all()
      serializer_class = ProductSerializer
      authentication_classes = [JWTAuthentication]
      permission_classes = [IsAuthenticated]
  
  
      def get_queryset(self):
          if self.request.user.is_superuser:
              return Product.objects.all()
          return Product.objects.filter(medical=self.request.info['medical'])
  </code></pre>
  <p>I literally don't have any idea how to do this.
  Thanks</p>