by Simone Federici - Michal Petrucha for EuroPython 2012
Currently Django models only support single column primary keys.
Multi-column primary keys support would improve Django integration with legacy databases (whose schema cannot be changed and usualy have multi-column primary keys).
This project allows the usage of django ORM with Multi-Column Primary Key and includes Foreign Key support.
In this talk we will explain the problem, propose a solution and present two projects aiming to solve it.
One of them is a pluggable app which monkey-patches Django’s ORM. Its obvious benefit is you can introduce it in a project without maintaining an unofficial Django fork.
The other one is the long-term solution approved of by the Django core team. It was part of last year’s Google Summer of Code and we will talk about what is ready and what is yet to be done before it is included into mainline Django.
Better yet, is an official solution available in Django itself?
I would like to use Django with some legacy/warehouse databases, but they ALL use composite keys.
Thanks for any feedback, suggestions, etc.
Patrick
but you cannot use the django join table orm system.
For the official support, you have to help Michal to implement the CFK feature.
If you need a quick solution as described in the abstract, use my library. It Is not official, is not completed, is not stable, but if you don0t use "django generic features" (not you case) it have to work. If you have problem contact me directly. s.federici@gmail.com
Here the django ticket:
https://code.djangoproject.com/ticket/373
The django wiki page:
https://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys
Here my monkeypatch project:
https://github.com/simone/django-compositekey
Here Michal django fork.
https://github.com/koniiiik/django/tree/soc2011/composite-fields