How to isolate data per customer, Django powered website

Posted by Sawwy on Stack Overflow See other posts from Stack Overflow or by Sawwy
Published on 2012-09-23T15:36:47Z Indexed on 2012/09/23 15:37 UTC
Read the original article Hit count: 263

Filed under:
|
|
|
|

I have recently started learning python and django and working on a project that includes building a website for collecting information from customers. I am currently trying to figure out best way to isolate the customer data (collected information is sensitive and should only be accessible by customer and the service provider). I found this post Postgresql - one database for everyone, or one-database per customer and my question is that can I automate the model inheritance with customer creation via admin? To be specific, when save() is called for adding customer via django admin, this should create the customer specific tables (create a new set of tables with 'company_name' -prefix).

For more information of the environment, I have extended the basic user registration with custom UserProfile adding 'company' and 'role' fields for each user. Upon login, the 'company' of the user will be checked to filter out tables without the 'company_name' prefix. 'Role' will further filter the which company-specific tables and set rights (view, edit).

will appreciate any suggestions if more elegant methods could be used to solve the data isolation problem than model inheritance.

© Stack Overflow or respective owner

Related posts about django

Related posts about table