[Answer]-Django-postgress: multiple primary keys are not allowed

1👍

After reading your answer I finally get the question, you are looking for composite keys in Django. Unfortunately this is not supported by Django yet. If you need it there are a few options:

  1. Try the Django Composite Key project: https://github.com/simone/django-compositekey

  2. Use the patches and explanation given on this page to add the support to Django: https://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys

  3. Use SQLAlchemy (http://www.sqlalchemy.org/) for querying as it does support this properly.

  4. Use a single primary key column in Django and read/write from/to a writable view which communicates with the actual table in the background.

👤Wolph

Leave a comment