title: How would i replicate this SQL query in Django Rest Framework using generics.ListAPIView and serializers.ModelSerializer
body: <p>Cant actually find anything like what i am trying to do with wanting to use case statements and left joins using DRF Django Rest Framework, yes this could be done on the front end of the project i am working on but id rather not have to let the front end potentially sending 100s of requests when loading a product list for example.</p>
  
  <p>Nothing i can really add to this but i have tried many different ways of doing the below</p>
  
  <pre><code>SELECT 
      p.itemno,
      CASE
          WHEN cp.price IS NULL THEN p.HighSell
          ELSE cp.price
      END AS price
  FROM
      api_product AS p
          LEFT JOIN
      api_customerprices AS cp ON p.itemno = cp.itemno
              AND cp.customerno = 'Examplecust'
  WHERE
      p.FreeStock &gt; 0
          or restockDate &gt; '1900-01-01'
  </code></pre>
  
  <p>Here Are my models:</p>
  
  <pre><code>class Product(models.Model):
      created_at = models.DateTimeField(auto_now_add=True)
      updated_at = models.DateTimeField(auto_now=True)
      itemno = models.CharField(max_length=100)
      description = models.TextField(null=True)
      colour = models.CharField(max_length=100, null=True)
      manufacturerCode = models.CharField(max_length = 100, null=True)
      RRP = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      SSP = models.DecimalField(max_digits=6, decimal_places=2,null=True)
      FreeStock = models.IntegerField(null=True)
      ItemSpec1 = models.CharField(max_length=100, null=True)
      ItemSpec2 = models.CharField(max_length=100, null=True)
      ItemSpec3 = models.CharField(max_length=100, null=True)
      ItemSpec4 = models.CharField(max_length=100, null=True)
      ItemSpec5 = models.CharField(max_length=100, null=True)
      ItemSpec6 = models.CharField(max_length=100, null=True)
      ItemSpec7 = models.CharField(max_length=100, null=True)
      ItemSpec8 = models.CharField(max_length=100, null=True)
      ItemSpec9 = models.CharField(max_length=100, null=True)
      ItemSpec10 = models.CharField(max_length=100, null=True)
      TI = models.IntegerField(null=True)
      HI = models.IntegerField(null=True)
      Item_Height = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      Item_Length = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      Item_Width = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      ProductPaging_Height = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      ProductPaging_Length = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      ProductPaging_Width = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      CartonHeight = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      CartonLength = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      CartonWidth = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      palletQty = models.IntegerField(null=True)
      cartonQty = models.IntegerField(null=True)
      restockDate = models.DateField(null=True)
      IPG = models.CharField(max_length=100, null=True)
      CatalogueTheme = models.CharField(max_length=100, null=True)
      Analysis2 = models.CharField(max_length=100, null=True)
      Electrical_or_Housewares = models.CharField(max_length=100, null=True)
      HighSell = models.DecimalField(max_digits=6, decimal_places=2, null=True)
      Analysis1 = models.CharField(max_length=100, null=True)
      Image = models.TextField(null=True, blank=True)
      MarketingText = models.TextField(null=True, blank=True)
      SearchTerms = models.TextField(null=True, blank=True)
      ItemVariant = models.CharField(max_length=100)
      Categories = models.CharField(max_length=249, null=True)
  
      def __str__(self):
          return self.itemno
  
  class CustomerPrices(models.Model):
      customerNo = models.CharField(max_length=20)
      itemno = models.CharField(max_length=20)
      price = models.DecimalField(max_digits=6, decimal_places=2)
      startDate = models.DateField()
      endDate = models.DateField()
  
      def __str__(self):
          return self.customerNo
  </code></pre>
  
  <p>Here are my Serializers</p>
  
  <pre><code>class OauthProdListSerializer(serializers.ModelSerializer):
      class Meta:
          model = Product
          fields = (
              'id',
              'itemno',
              'description',
              'colour',
              'RRP',
              'SSP',
              'manufacturerCode',
              'FreeStock',
              'restockDate',
              'Image',
              'HighSell',
              'ItemVariant',
              'Categories'
          )
  
  class OCustomerPricesSerializer(serializers.ModelSerializer):
      class Meta:
          model = CustomerPrices
          fields = (
              'id',
              'customerNo',
              'itemno',
              'price'
          )
  </code></pre>