Reputation: 19
I have two primary keys in a table i know django does not support multiple PK in same table i used unique_identifier but when i do syncdb all columns are not created
class SODIOrder(models.Model):
sodi_order_num = models.CharField(max_length=50, primary_key=True)
sodi_order_version = models.CharField(max_length=50,primary_key=True)
service_identifier = models.CharField(max_length=50)
telephone_number = models.CharField(max_length=12)
insert_timestamp = DateTimeUTCField(auto_now_add=True)
class Meta:
unique_together = (("sodi_order_num","sodi_order_version"))
sodi_order_version
is not created can anyone help me with this??
Upvotes: 1
Views: 4122
Reputation: 5194
remove primary_key=True
from your model fields and change unique_together
as tuple of tuples
like this:
class SODIOrder(models.Model):
sodi_order_num = models.CharField(max_length=50)
sodi_order_version = models.CharField(max_length=50)
service_identifier = models.CharField(max_length=50)
telephone_number = models.CharField(max_length=12)
insert_timestamp = DateTimeUTCField(auto_now_add=True)
class Meta:
unique_together = (("sodi_order_num","sodi_order_version"),)
Upvotes: 7