Coder Social home page Coder Social logo

django-api-rest's Introduction

Django Rest API

This is a REST API to retrieve customers informations.

Installation

For best pratices, we can create a new environment and activate it to hold the app. I use conda to create my env, but you can use python,etc.

first of all you need to go to the project directory.

cd mysite

There will be a requirement.txt that holds all of the packages needed to run the project.

pip install -r requirements.txt

Usage

As requested in Question 1, we will use a Django management commad to import our customers.csv file into the database.

python manage.py command 

Please note that:

  • it will take some time to process.
  • I have shared my API key just for the matter of speeding up the testing. you can change that inside of the command.py script inside of management/commands folder.
  • Since this step have already been done, we might run into an exception: Table 'myapi_customer' already exists. you can just delete the database file in order for it to work properly. if so please run the following command to migrate the changes to the database:
python manage.py makemigrations
python manage.py migrate

In this step we are importing all data inside our file to the database. Besides to that we are adding two columns longitude and latitude for each city.

Then we can proceed to running the server.

python manage.py runserver

Accessing the localhost: http://127.0.0.1:8000/

All customers are shown there on the index page, we can select a customer ID and submit the selection to retrieve data about that specific customer.

Notes

I have used Django Rest Api Framework which already provides all the CRUD (I have restricted the CRUD to [Get,Post,Head] Only) and HTML and it can be accessed through this link http://127.0.0.1:8000/framework.

Contribution

Hedy Anouar Krid

Feel free to email me on [email protected] for any doubts.

django-api-rest's People

Watchers

Hedy avatar

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.