This REST API application provides functionality of edit, watch shops, address and their relationships
First of all, it is necessary to install dependencies marked in requirements.txt
pip3 install -r requirements.txt
The first thing (related to project itself) you have to do is migrate
python3 manage.py migrate
Then, you should populate database with data in fixture data.json
located in main/fixtures/
python3 manage.py loaddata data
You can run tests with command
python3 manage.py test
All tests should run properly. Here you go!
has 4 fields: id, name (string), address(address instance), last_changed(datetime; it is set automatically without any user action)
has 3 fields: id, street(string), home(integer; it's number of building in the street)
GET /shop/
get all shops
GET /address/
get all addresses
GET /shop/%ID%/
details of specific shop with %ID% primary key
GET /address/%ID%/
details of specific address with %ID% primary key
GET /address/%ID%/shops/
related shops to address with %ID% primary key
POST /shop/
create new shop
{
"name": "name_of_new_shop",
"address": primary_key_of_related_address
}
{
"id": primary_key_of_created_shop,
"name": name_of_create_shop,
}
POST /address/
create new address
{
"street": "string_with_street_name",
"home": interger_of_home_number
}
{
"id": primary_key_of_created_address
}
There's a single endpoint PATCH to change shop's address. It can be done with
PATCH /shop/%ID%
{
"address": id_of_new_address
}