Coder Social home page Coder Social logo

django_api's Introduction

DJANGO API

Installation

  1. Clone this repo to your local directory
  2. Enable python virtual environment in the source directory
  3. Run pip3 install -r requirements.txt to install all the required packages
  4. Run python3 manage.py makemigrations
  5. Go to graph_api.schema and replace the api_key = "" with your api key
  6. Run python3 manage.py migrate
  7. Run python3 manage.py migrate --run-syncdb
  8. Create a super user for securing the api python3 manage.py createsuperuser and follow the prompts
  9. Run python3 manage.py migrate loaddata dummy.json
  10. Run python3 manage.py runserver to start the server at https://127.0.01/8000

Retrieving Data

The program when started runs locally on port 8000. This opens an admin page that'll require a login.

Creating a simple query

Navigate to https://127.0.01/8000/admin/graphql in your browser to access a graphiql user interface.

Getting all Customers


    query getCustomers{
        customers{
            code
            name
            orders{
                item
                amount
            }
        }
    }

Getting all Orders

    query getOrders{
        orders{
            item
            amount
            time
        }
    }

Creating an Order

mutation createOrder {
    createOrder(input: {item: "Tortillas", amount: 200, time: 2300}) {
    ok
    order {
      item
      amount
      time
    }
  }
}

Creating a Customer

mutation createCustomer {
    createCustomer(input: {code: 714044854, name: "Tom Hanks", orders: [{id: 1}, {id: 2}]}) {
    ok
    customer {
      code
      orders {
        id
        item
        amount
        time
      }
    }
  }
}

Africastalking SMS integration

In your project's root directory, rename .env.sample to .env and fill in the variable names with the corresponding values from Africastalking SDK

When the mutation for creating a new customer having a particular order is run, the api automatically takes the code, user's phone numner and sends an order complete message

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.