Skip to content

masudranam/pythonDjango

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Django Project Initialization

#1. Create a virtual environment: bash python -m venv venv

  1. Activate the virtual environment:

    source venv/bin/activate
  2. Install Django:

    pip install django
  3. Save the installed packages to requirements.txt:

    pip freeze > requirements.txt
  4. Start a new Django project:

    django-admin startproject <project-name>

API Design

Create Product

  • Method: POST
  • Endpoint: api/v1/products
  • Authentication: Basic or Bearer Token
  • Request Body:
    {
        "name": "product_name",
        "price": "price"
    }
  • Response:
    • 1xx: Informational responses
    • 2xx: Successful responses
      • 201: Product created successfully
    • 4xx: Client error responses
      • 400: Bad request (invalid input)
      • 401: Unauthorized
    • 5xx: Server error responses
      • 500: Internal server error

Get All Products

  • Method: GET
  • Endpoint: api/v1/products
  • Authentication: Basic or Bearer Token
  • Request Body: None
  • Response:
    {
        "id": "_id"
    }
    • 1xx: Informational responses
    • 2xx: Successful responses
      • 200: OK (list of products)
    • 4xx: Client error responses
      • 401: Unauthorized
    • 5xx: Server error responses
      • 500: Internal server error

Get Product by ID

  • Method: GET
  • Endpoint: api/v1/products/{id}
  • Authentication: Basic or Bearer Token
  • Request Body: None
  • Response:
    {
        "id": "_id"
    }
    • 200: OK (product found)
    • 401: Unauthorized
    • 404: Not found
    • 500: Server error

Update Product

  • Method: PUT or PATCH
  • Endpoint: api/v1/products
  • Authentication: Basic or Bearer Token
  • Request Body:
    • PUT: Full object
    • PATCH: Partial object
  • Response:
    {
        "id": "_id"
    }
    • 200: OK (product updated)
    • 401: Unauthorized
    • 404: Not found
    • 500: Server error

Delete Product

  • Method: DELETE
  • Endpoint: api/v1/products/{id}
  • Authentication: Basic or Bearer Token
  • Request Body: None
  • Response:
    {
        "delete": "success"
    }
    • 200: OK (product deleted)
    • 401: Unauthorized
    • 404: Not found
    • 500: Server error

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages