All the credit goes to Nicolas Mesa https://blog.nicolasmesa.co/posts/2018/10/saas-like-isolation-in-django-rest-framework/
Run in virtual environment:
python manage.py migrate
python manage.py createsuperuser
Django SaaS like isolation using django-rest-framework
to create accounts system for User and Company model.
Every new User have the Company tied to his account
The project also has the user_messages
app by which users can transfer messages among other users
Every logging in user may see only his messages
api/v1/accounts/ - to create a new account
api/v1/accounts/users/ - to see the list of the users(every created user - seems like a bug)
api/v1/accounts/company - logged in user may see only his company
api/v1/user-messages/ - to send a message or see existing messages of the the current logged in user
Go to http://127.0.0.1:8000/api/v1/accounts/ to create a new account
Go to http://127.0.0.1:8000/api/v1/accounts/users/ to see every user but only if you are logged in
Go to http://127.0.0.1:8000/api/v1/accounts/company to see the current user company
Go to http://127.0.0.1:8000/api/v1/user-messages/ to send a message to other users(logged in user sees only his messages)
The project also uses the one fixture to create 'non existent company' in the Company model
it loads on first python manage.py migrate
run