Giter Club home page Giter Club logo

bulk-insert's Introduction

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"
  }
]'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.