REST API example for Pizza Order Demo.
In order to run DRF_api_example, please install postgreSQL and both the Python runtime and development environments. The following instructions should apply to computers running a version of the Linux or OS X operating systems.
- Download the DRF_api_example code by running
git clone https://github.com/jahandaniyal/DRF_api_example.git
- Visit the DRF_api_example directory:
cd DRF_api_example
- Create a virtual environment for the project:
virtualenv venv
- Start using the virtual environment:
source venv/bin/activate
- In
/api_example/settings.py
file, change the postgres user credentials:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'api_example_db',
'USER': 'postgres',
'PASSWORD': '123',
'HOST': 'localhost',
'PORT': '5432'
}
}
- Install all requirements:
pip install -r requirements.txt
- Finally, start the Django server:
python manage.py runserver 127.0.0.1:8080
- Visit
http://127.0.0.1:8080/orders/
The following operations are supported -
- Create a new Order
- Get all orders created by the customers
- Get a specific order
- Update an Order
- Delete an Order
Tests has been included in orders/tests.py
for the following cases -
- Create a new Order
- Get records of order created by customers
- Update an order
- Partial update of an order e.g only changing
customer address
- Deleting a order