title: Multiple field foreign key in django
body: <p>I have two models in django with definitions below.
  CreativeStatus model :</p>
  
  <pre><code>class RtbdCreativeStatus(models.Model):
      creative_id = models.CharField(max_length=500, primary_key=True)
      advertiser_id = models.CharField(max_length=100, primary_key=True)
      exposure_level = models.CharField(max_length=125)
      modified_on = models.DateTimeField()
      modified_by = models.CharField(max_length=100)
  
  
  class RtbdCreative(models.Model):
      id = models.AutoField(primary_key=True)
      advertiser_id = models.ForeignKey(RtbdCreativeStatus, on_delete=models.CASCADE)
      creative_id = models.ForeignKey(RtbdCreativeStatus, on_delete=models.CASCADE)
      country_id = models.IntegerField()
      adm = models.CharField(max_length=255, null=True, blank=True)
      sample_url = models.CharField(max_length=500)
      landing_page = models.CharField(max_length=500, null=True, blank=True)
      html = models.CharField(max_length=500)
      creative_attributes = models.CommaSeparatedIntegerField(max_length=150, null=True, blank=True)
      advertiser_domains = models.CharField(max_length=500)
      description = models.CharField(max_length=500, null=True, blank=True)
      created_on = models.DateTimeField(auto_now=True, auto_now_add=True)
      creative_type = models.CharField(max_length=50, null=True, blank=True)
      demand_source_type_id = models.IntegerField()
      revalidate = models.BooleanField(default=False)
  </code></pre>
  
  <p>(creative_id, advertiser_id ) combination is unique in my CreativeStatus table . I want that combination to be my foreign key for Creative table. I tried adding it but i get this error .<a href="https://i.stack.imgur.com/v1Zjq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/v1Zjq.png" alt="Screenshot of the error in django"></a> </p>
  
  <p>1)How do i achieve this join with two key combination as my foreign key . </p>
  
  <p>2)What should be my query to fetch all the creatives with their status from CreativeStatus table .</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>on reading the answers below , i updated my model as mentioned below :</p>
  
  <pre><code>class RtbdCreative(models.Model):
      id = models.AutoField(primary_key=True)
      advertiser_id = models.ForeignKey(RtbdCreativeStatus, to_field='advertiser_id', related_name='advertiser', db_column='advertiser_id', on_delete=models.CASCADE)
      creative_id = models.ForeignKey(RtbdCreativeStatus, to_field='creative_id', related_name='creative', db_column='creative_id', on_delete=models.CASCADE)
      country_id = models.IntegerField()
      adm = models.CharField(max_length=255, null=True, blank=True)
      sample_url = models.CharField(max_length=500)
      landing_page = models.CharField(max_length=500, null=True, blank=True)
      html = models.CharField(max_length=500)
      creative_attributes = models.CommaSeparatedIntegerField(max_length=150, null=True, blank=True)
      advertiser_domains = models.CharField(max_length=500)
      description = models.CharField(max_length=500, null=True, blank=True)
      created_on = models.DateTimeField(auto_now=True, auto_now_add=True)
      creative_type = models.CharField(max_length=50, null=True, blank=True)
      demand_source_type_id = models.IntegerField()
      revalidate = models.BooleanField(default=False)
  </code></pre>
  
  <p>Now i am getting this error<a href="https://i.stack.imgur.com/swdeV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/swdeV.png" alt="enter image description here"></a> . I have combination of advertiser_id , craetive_id as unique . But django expects both to be unique. What can i do to make it work ?</p>