Hi, thanks for the answer.  Of course, the moment I posted the question I 
figured out what it was.

I ended up checking my primary keys, and found that they didn't have unique 
constraints.  I added them and all was fine.

Must have fallen off during an import.

On Sunday, 10 November 2019 13:55:06 UTC-4, Integr@te System wrote:
>
> Hi Issuer, 
>
> Check your tracker_passenger.
>
> https://docs.djangoproject.com/en/2.2/ref/models/fields/#django.db.models.ManyToManyField
>
>
> On Sun, Nov 10, 2019, 21:40 Malibu <mali...@gmail.com <javascript:>> 
> wrote:
>
>> 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.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/db29f623-eecd-4b58-8b70-d2fcd063aaaf%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/db29f623-eecd-4b58-8b70-d2fcd063aaaf%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/76dfb80d-6310-4a4e-a47b-244f00e04ac0%40googlegroups.com.

Reply via email to