Django app API demo will allow the user call a API and get back a list of active items.
The items will be customisable by the Django default admin pages.
The API will respond with a list of all currently active items.
- An API that responds to a
GETrequest and returns a list of active items. - Django admin page where the items parameters can be customised and new items can be added.
- Item attributes must consist of code, name and active.
- Ensure that duplicate items cannot be added.
| Code | Name | Active |
|---|---|---|
| KET | Kettle | true |
| SPN | Spoon | fale |
| FRK | Fork | true |
We now want to group these items up into the specific categories mentioned below.
Once you have grouped each item into a category, add a POST request endpoint.
The API will accept the category name and return a list of items in that category that are active.
| Category | Code |
|---|---|
| Appliance | KET |
| Cutlery | SPN |
| Cutlery | FRK |
- Think about how you want these items to be grouped in the database and an optimum way of querying for these items.
-
Clone this repo.
-
Create a virtual env
-
Install virtual env
pip install virtualenv -
cd basic-django-apiandvirtualenv basic-django-api -
To begin using the virtual environment, it needs to be activated:
source basic-django-api/bin/activate
-
-
Install the dependency (
pip3 install -r requirements.txt) -
Once all are setup go to
~/basic-django-api/basic_api/(cdcmd) and runpython manage.py runserver
Once the server is running you can access to the django admin trougth the url:
http://127.0.0.1:8000/admin
The admin access is Username: admin, Password: a1b2c3d4
This API accept two entries point:
-
GETon/itemgive a list of active items. -
POSTon/itemcreate an active item. The minimum required is{ "name": "spoon", "code": "SPN"} -
GETon/item/{id}give a the detail of the item. -
PUTon/item/{id}Update the item. -
DELETEon/item/{id}Delete the item. -
GETon/categorygive a list of categories. -
POSTon/categorycreate a category. The minimum required is{ "name": "appliance"} -
GETon/category/{id}give a the detail of the category. -
PUTon/category/{id}Update the category. -
GETon/category/{name}give a list of active items for this category.