I'm looking for a way to register and authenticate custom users accross mutiple databases using Django and postgreSQL.
The application will be cross countries (still brainstorming). Regarding the different laws we need to store the users details inside their own country. For exemple, US users must have data stored in the US, Canadians users stored in Canada and Europeans users stored in Europe.
The problem is that Django (1.11) doesn’t currently provide any support for foreign key or many-to-many relationships spanning multiple databases.
So I came up with 2 options at the moment but I can't see the perfect one. I'm asking if you would have a better solution.
- Option 1: using postgres_fdw (PostgreSQL foreign data wrapper) Manually creating localized (us, can, euro) databases to store users’ details https://www.postgresql.org/docs/9.6/static/postgres-fdw.html
Then integrate Django with a legacy database
Pros: Supports foreign database relationships
Cons: Manual migration, manual integration, custom scripts.
- Option 2 : Skip Django referential integrity https://gist.github.com/gcko/de1383080e9f8fb7d208
Pros: Easier Django integration
Cons: Risk of data corruption. I would avoid it!!
Thanks
Django: 1.11
PostgreSQL 9.6
Python 3