Hi there. I've been doing Django for awhile but I am stumped on this one.. I have a many to many relationship with a 'through' definition
main.models:
class Client(models.Model):
uid = models.CharField(max_length=128, unique=True)
key = models.CharField(max_length=128)
img = models.TextField()
version = models.CharField(max_length=20)
lastConnection = models.DateTimeField()
role = models.CharField(max_length=128,default="")
tracker.models:
from main.models import Client
class PassengerAccess(models.Model):
passenger = models.ForeignKey('Passenger',on_delete=models.CASCADE)
client = models.ForeignKey(Client,on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True,blank=True)
selected = models.BooleanField(default=False)
class Passenger(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
access_code = models.CharField(max_length=32)
school_division = models.ForeignKey(SchoolDivision)
open_clients = models.ManyToManyField(Client, through='PassengerAccess')
The error I get when I try to migrate is: django.db.utils.ProgrammingError: there is no unique constraint matching given keys for referenced table "tracker_passenger"
Any solution to this error appears to be related to a foreign key that is referencing a field that is not unique, but in this case passenger and client should both be accessing the primary key should they not? I always use plain integer primary keys.
Any suggestions on how to troubleshoot this would be appreciated.