title: Best and fastest method to add only unique records based on certain fields in Django
body: <p>I have a model with multiple fields where data is text type for the most part. I want to put a validation that from now on if a new record is being added, it should be unique based on 3 fields. Here one of the fields is a one-to-many field as is in another table.</p>
  
  <p>I can try fetching all the records and start checking them using for-loop. I tried using annotate but it seems to help if the record is already in the table, but I want to do this validation before adding. I need a fast method for this validation.</p>
  
  <pre><code>class Product(models.Model):
      brand = models.TextField(default='{}', null=True)
      sub_brand = models.CharField(null=True)
      .
      .
      .
  
  class ProductNetWeight(models.Model):
      product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='product_net_weight')
      net_weight = models.CharField(null=True)
  </code></pre>