Project made with Django + PostgreSQL + DRF for Onidata interview
Install docker-ce and docker-compose from each documentation
On the project folder run the following commands:
$ make config.env
to copy the file.env.example
to.env
$ make build
to build docker containers
Simply run the command $ make up
and voilà.
This command will start 3 services on your machine:
- Django server on http://0.0.0.0:8000
- PgAdmin server on http://0.0.0.0:5050
- PostgreSQL service on port 5432
On the project folder:
- run the command
$ make test
or$ make test app=$(app_name)
. You may run the command$ make coverage
instead. - run the command
$ make flake8
Django Admin Site is enabled for the project on http://0.0.0.0:8000/admin.
The command $ make populate.superuser
may be used to create the superuser User(username='superuser', password='@Admin123')
.
Access the localhost server and browse the api.
You may interact with the API via browser or via http request softwares such as Insomnia
BasicAuthentication
, SessionAuthentication
and JWTAuthentication
are enabled on the API.
Pass the token following the curl example. If there's some confusion about JWT read about it on JWT Oficial Documentation or the lib drf-simplejwt
curl \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiY29sZF9zdHVmZiI6IuKYgyIsImV4cCI6MTIzNDU2LCJqdGkiOiJmZDJmOWQ1ZTFhN2M0MmU4OTQ5MzVlMzYyYmNhOGJjYSJ9.NHlztMGER7UADHZJlxNG0WSi22a2KaYSfd1S-AuT7lU" \
http://localhost:8000/api/some-protected-view/
Install Insomnia Rest from the official website.
Import the file insomnia_data.json
located on the project folder.
Activate the Onidata
workspace and Onidata
environment