Skip to content

app-generator/sample-django-api-drf

Repository files navigation

Simple starter built with Python / Django Rest / SQLite3 and JWT Auth. The authentication flow is based on json web tokens. Forked from Django API Server. For more information please access the project documentation.


Features:

  • Simple, intuitive codebase - built for beginners (can be extended with ease)
  • Django / Django REST / SQLite3 - a simple, easy to use backend
  • Authentication with JWT (JWT login, JWT logout)
  • Testing, Docker
  • Forked and extended from Django API Server with more features
    • api/transactions/create - create transaction
    • api/transactions/edit/id- edit transaction
    • api/transactions/delete/id - delete transaction
    • api/transactions/get/id - get specific transaction
    • api/transactions/get - get all transactions

Can be used with other UI projects for a complete fullstack experience


Support:

  • Github (issues tracker), Email: support @ appseed.us
  • Discord: LIVE Support (registered AppSeed Users)

Django API Server - Open-source Django Starter provided by AppSeed.


Requirements

  • Django==3.2.5
  • djangorestframework==3.12.4
  • PyJWT==2.1.0
  • django-cors-headers==3.7.0

How to use the code

Clone the sources

$ git clone https://github.com/app-generator/api-server-django-sample.git
$ cd api-server-django-sample

Create a virtual environment

$ virtualenv -p python3 venv
$ source venv/bin/activate

Install dependencies using pip

$ pip install -r requirements.txt

Start the API server

$ python manage.py migrate
$ python manage.py runserver

The API server will start using the default port 8000.


Docker execution


Get the code

$ git clone https://github.com/app-generator/api-server-django.git
$ cd api-server-django

Start the app in Docker

$ docker-compose up -d --build

Visit http://localhost:5000 in your browser. The API server will be running.


API

For a fast set up, use this POSTMAN file: api_sample

Register - api/users/signup

POST api/users/signup
Content-Type: application/json

{
    "username":"test",
    "password":"pass", 
    "email":"test@appseed.us"
}

Login - api/users/login

POST /api/users/login
Content-Type: application/json

{
    "password":"pass", 
    "email":"test@appseed.us"
}

Logout - api/users/logout

POST api/users/logout
Content-Type: application/json
authorization: JWT_TOKEN (returned by Login request)

{
    "token":"JWT_TOKEN"
}


Django API Server Sample - Provided by AppSeed App Generator