Skip to content

ZeroNiki/Django-RestAPI-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple implementation of RestAPI (Django)

For FastAPI

A simple example of using RestAPi on Django

Install

git clone https://github.com/ZeroNiki/Django-RestAPI-Example.git

cd Django-RestAPI-Example
python3 -m venv venv

source venv/bin/activate
pip install -r requirements.txt

Usage

cd app

python3 manage.py makemigrations # if necessary
python3 manage.py migrate

python3 manage.py createsuperuser # create user for admin panel

python3 manage.py runserver # go to http://127.0.0.1:8000

/ - Django API root
/admin - admin panel

CURL

get all data:

curl --header "Content-Type: application/json" \
--request GET \
--url "http://127.0.0.1:8000/api/todo/"

Add data:

curl --header "Content-Type: application/json" \
--request POST \
--data '{"title": "Test Todo"}' \
http://127.0.0.1:8000/api/todo/

Update data:

curl --header "Content-Type: application/json" \
--request PUT \
--data '{"title": "Update test Todo"}' \
http://127.0.0.1:8000/api/todo/{id}

Delete data:

curl --request DELETE http://127.0.0.1:8000/api/todo/{id}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages