Skip to content

A Django API designed to handle the insertion of products and their variants.

License

Notifications You must be signed in to change notification settings

tin3ga/bulk-insert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bulk-insert

A Django API designed to handle the insertion of products and their variants, utilizing Django REST Framework. It supports both single and bulk data insertion operations.

GitHub top language GitHub License GitHub last commit

Technologies

Quick Start

  1. Clone the repo:
$ git clone https://github.com/tin3ga/bulk-insert.git
$ cd bulk-insert
  1. Initialize and activate a virtualenv:
# windows
$ python -m venv venv
$ venv\Scripts\activate

# mac/linux
$ python -m venv venv
$ source env/bin/activate or . venv/bin/activate
  1. Install the dependencies:
$ pip install -r requirements.txt
  1. Navigate to bulk_insert:
$ cd bulk_insert
  1. Make Migrations:
$ python manage.py makemigrations
$ python manage.py migrate

  1. Create SuperUser:

An auth token is automatically generated for new users and is to be contained in request headers when making api calls. Make sure to note your superuser name and password.

$ python manage.py createsuperuser

  1. Run tests:
$ python manage.py test

  1. Run the development server:
$ python manage.py runserver

Endpoints

  1. Retrieve Auth Token
curl --request POST \
  --url http://127.0.0.1:8000/api-token-auth/ \
  --header 'content-type: multipart/form-data' \
  --form username=**your username** \
  --form password=**your password**
  
  1. Bulk Insert Products
curl --request POST \
  --url http://127.0.0.1:8000/products/ \
  --header 'AUTHORIZATION: Token **your token**' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/8.6.1' \
  --data '[
	{
		"name": "Yoghurt",
		"image": null,
		"variants": []
	},
	{
		"name": "Milk",
		"image": null,
		"variants": []
	},
	{
		"name": "Juice",
		"image": null,
		"variants": []
	}
]'

  1. Bulk Insert Product Variants
curl --request POST \
  --url http://127.0.0.1:8000/product_variants/ \
  --header 'AUTHORIZATION: Token **your token**' \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: insomnia/8.6.0' \
  --data '[
  {
    "sku": "SKU001",
    "name": "Variant 1",
    "price": 19.99,
    "details": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
    "product_id": "3"
  },
  {
    "sku": "SKU002",
    "name": "Variant 2",
    "price": 29.99,
    "details": "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
    "product_id": "1"
  },
  {
    "sku": "SKU003",
    "name": "Variant 3",
    "price": 39.99,
    "details": "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.",
    "product_id": "1"
  }
]'

About

A Django API designed to handle the insertion of products and their variants.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages