Django REST framework приложение, с переопределённым пользователем и списком организаций в которых он состоит
To implement ManyToMany relationship between user and organization we need 3 tables: user, organization and table with keys
- There is an endpoint for user creation (registration), listing all users with list of organizations called
users
(http://127.0.0.1:8000/api/users/) methods: GET, POST
Also to get user by ID add his id to the end of url (.../1/) (Anyone can GET info, but only owner can edit by PUT or PATCH)
2) For listing all organizations with their users we have an endpoint organizations
(http://127.0.0.1:8000/api/organizations/) methods: GET, POST
Make POST request to endpoit token
(http://127.0.0.1:8000/api/token/) to get access token for authentication and then use it in headers (key: Authentication value: Bearer ACCESS_TOKEN)
To start this app you need to:
- Clone this repo and move to project
git clone https://github.com/ApostL78/orgs_api.git && cd orgs_api
- Create and activate
venv
python3 -m venv venv && source ./venv/bin/activate
- Create environment variables
cp .env.example .env
and then put your values
- Install all requirements
pip install -r requirements.txt
- Migrate and run server
python3 manage.py migrate && python3 manage.py runserver
After the server starts, navigate to http://localhost:8000/swagger/
in your web browser