[Answered ]-Django two foreign keys unique record

2👍

You should take a look at unique together! It may solve your issue.

👤Alvaro

0👍

Django does not yet support compound indicies. The accepted solution is to register a post_syncdb signal handler — https://docs.djangoproject.com/en/1.6/ref/signals/#post-syncdb

Here’s the template (you’ll need to fill in the appropriate details):

from django.db import connection
from django.db.models.signals import post_syncdb
def callback(sender, **kwargs):
    cur = connection.cursor()
    cur.execute('CREATE UNIQUE INDEX ...')

post_syncdb.connect(callback, sender=app.models)

Leave a comment