Setup steps
- Clone this repository on your local machine
- Go inside the Fatmug directory
- Install django using
pip install django
(Make sure python is installed on your system) - We are using rest_framework, so use
pip install djangorestframework
to use it. - Use the command
python manage.py migrate
which will create required tables in your database. - For token based authentication, we have to create a user using
python manage.py createsuperuser
to generate a token. - After creating a user, use the command
python manage.py drf_create_token <your_username>
your result will be like thisGenerated token 893f38d0382f9bfaaf69784cfbd5bb31110d1856 for user <username>
- Now, run the server using
python manage.py runserver
Now you api is live on localhost 8000
I have used POSTMAN to test the endpoints of the api.
Because, of encapsulating the urls by token based authentication, we have to add the token everytime in the request in its header.
We have to add it like this: Authorization: Token 893f38d0382f9bfaaf69784cfbd5bb31110d1856
For the post request, you have to enter the url in address bar and select the POST from the dropdown. Enter the data inside Body as shown in image:
In this way, you can use POSTMAN to check your all the endpoints.