title: Can one table has more than one primary key in Django?
body: <p>I have following table structure.<br>
  When I try to migrate, I got following error.  </p>
  
  <blockquote>
    <p>django.db.utils.OperationalError: table "certificate_light" has more
    than one primary key  </p>
  </blockquote>
  
  <p>However, I found other <a href="https://stackoverflow.com/questions/2011268/can-a-database-table-contains-more-than-one-primary-key">stack overflow page</a> saying that one table can have more than one primary key in RDBMS.<br>
  Can anyone know how I can implement table having more than one primary key in Django?</p>
  
  <p><strong>models.py</strong>  </p>
  
  <pre><code>class Certificate(models.Model):
      name=models.CharField(max_length=20)
  
  class Zone(models.Model):
      zone=models.CharField(max_length=20)
      conditioned=models.BooleanField(default=True)
  
  class Light(models.Model):
      certificate=models.ForeignKey(Certificate, on_delete=models.CASCADE,related_name='certificate')
      zone=models.ForeignKey(Zone, on_delete=models.CASCADE,related_name='lightzone')
      lpd=models.IntegerField()
      sensor=models.BooleanField(default=True)
  </code></pre>
  
  <p><strong>Update</strong><br>
  I added detail error message as below.  </p>
  
  <pre><code>  Applying certificate.0007_auto_20181126_1155...Traceback (most recent call last):
    File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\utils.py", line 63, in execute
      return self.cursor.execute(sql)
    File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\sqlite3\base.py", line 326, in execute
      return Database.Cursor.execute(self, query)
  sqlite3.OperationalError: table "certificate_light" has more than one primary key
  </code></pre>