An API to keep track of daily calories consumed by user. Also users can set their daily maximum calorie consumption limit. Once this limit exceeds, every food-item consumed thereafter shall have a boolean field set to True for calories_exceeded field.
$ git clone https://github.com/suvhotta/calorie_app_DRF.git
$ cd calorie-tracker-django-restframework
$ pipenv install
$ pipenv shell
$ python manage.py makemigrations
$ python manage.py migrate
$ python manage.py runserver
- Admin : Can add/fetch/remove both users and food-items.
- User Manager : Can add/fetch/remove only users.
- Normal User : Can add/fetch/remove self added food-items.
To create an admin with default username: admin, password: admin, and max_calories: 2000
$ python manage.py create_admin
To specify the username, password or max_calories:
$ python manage.py create_admin --username <username>
--password <password> --max_calories <max_calories>
The admin account can be therafter used to create more users.
There isn't any limitation on username and password, however the max_calories should be an integer.
In a RESTful API, endpoints (URLs) define the structure of the API and how end users access data from our application using the HTTP methods - GET, POST, PATCH, PUT, DELETE.
Endpoint | HTTP Method | CRUD | RESULT |
---|---|---|---|
register | POST | CREATE | creates new user |
users | GET | READ | list of all users |
users/pk | GET | READ | Single User info |
users/pk | PUT | UPDATE | Updates a user |
users/pk | PATCH | UPDATE | Updates a user |
users/pk | DELETE | DELETE | Deletes a user |
fooditem | POST | CREATE | Creates a food entry |
fooditem | GET | READ | List of all fooditems |
fooditem/pk | GET | READ | Details about a particular food entry |
fooditem/pk | PUT | UPDATE | Updates a food entry |
fooditem/pk | PATCH | UPDATE | Updates a food entry |
fooditem/pk | DELETE | DELETE | Deletes a food entry |
login | POST | CREATE | Creates a token for user login |