Skip to content

SergSm/test-django-saas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 

Repository files navigation

test-django-saas

All the credit goes to Nicolas Mesa https://blog.nicolasmesa.co/posts/2018/10/saas-like-isolation-in-django-rest-framework/

Steps after installation:

Run in virtual environment:

python manage.py migrate
python manage.py createsuperuser

Description

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

Endpoints:

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

Endpoints use cases:

Go to http://127.0.0.1:8000/api/v1/accounts/ to create a new account

api/v1/accounts

Go to http://127.0.0.1:8000/api/v1/accounts/users/ to see every user but only if you are logged in

api/v1/accounts/users

Go to http://127.0.0.1:8000/api/v1/accounts/company to see the current user company

/api/v1/accounts/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)

/api/v1/user-messages

Additional info

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