Skip to main content

async REST framework

Project description

Kame

Async REST framework for tortoise-orm and starlette

Requirements

Installation

pip install kame

Usage

Having the following tortoise model:

from tortoise.models import Model
from tortoise import fields

class Tour(Model):
    id = fields.IntField(pk=True)
    name = fields.TextField()
    data = fields.JSONField(default=dict)

    def __str__(self):
        return self.name
  1. Create a serializer
from kame import serializers

class TourSerializer(serializers.ModelSerializer):

    class Meta:
        model = Tour
        fields = ['id', 'name', 'description', 'parent', 'active', 'image', 'descendant_ids']
  1. Create a viewset
from kame import viewsets

class TourViewSet(viewsets.ModelViewSet):
    queryset = Tour.all
    serializer_class = TourSerializer
  1. Register a route
from kame import routers

router = routers.DefaultRouter()

router.register('/tours', TourViewSet, basename="tour")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for kame, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size kame-0.0.3.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page