On Fri, 21 Apr 2017, Michal Petrucha wrote:
I have bad news for you – Django does not at this point in time have support for multi-column primary keys. A large part of the ORM is built around the assumption that each model instance is identified by a single field acting as its primary key.
Michal, Ah, okay. I did not get far enough into the docs to read this.
For the foreseeable future, though, I'd strongly recommend that you save yourself a lot of trouble, and just add a surrogate primary key field to all your tables and models.
I can live with this. Many, if not most, of the databases I've developed will have a table which stores a unique value based on more than one other table row. But, using a surrogate key works as long as I can retrieve the appropriate records. Guess I'll get to that point in the not too distant future. What about my other question? When I want to limit acceptable strings in a data entry field to a provided list, as in postgres's check constraint? Is Mike's suggestion of clean() the way to handle these? Thanks very much, Rich