I'm using a hand built (Postgres) database with Django. With "inspectdb" I was able to automatically create a model for it. The problem is that some tables have multiple primary keys (for many-to-many relations) and they are not accessible via Django.
What's the best way to access these tables?
Django provides a utility to auto-generate models from an existing database via inspectdb command. The output file will be saved to your current directory. Move that file to the correct app and you have a good starting point for further customization.
MySQL and PostgreSQL work best with Django.
There is no way to use composite primary keys in Django's ORM as of now (up to v1.0.2).
I can only think of three solutions/workarounds:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With