Yet Another Resftul Django framework
Project description
Yard is an API oriented framework that aims to simplify the developer’s work when implementing complex API design. It provides a neat, familiar and easy way to control the logic for acceptable parameters in each http-GET-request.
Basic Usage
views.py
from yard import resources, forms, fields from models import Book class BooksResource(resources.Resource): # model associated with the resource (mandatory) model = Book # used in the index and show methods fields = { 'id': fields.Integer, 'title': fields.Unicode, 'publication_date': fields.Unicode, 'author': { 'age': fields.Integer, 'name': fields.Unicode } } class Parameters: year = forms.IntegerParam( alias='publication_date__year', min=1970, max=2012 ) title = forms.CharParam( required=True ) genre = forms.CharParam( alias='genres' ) author = forms.CharParam( alias='author__id' ) house = forms.CharParam( alias='publishing_house__id' ) __logic__ = year, title, genre & (author|house) def list(self, request, params): #GET /resource/ return Book.objects.filter( **params ) def detail(self, request, book_id): #GET /resource/:id/ return Book.objects.get( id=book_id ) def create(self, request): #POST /resource/ return 401, 'You are not authorize' def update(self, request, book_id): #PUT /resource/:id/ ... def destroy(self, request, book_id): #DELETE /resource/:id/ ...
urls.py
from views import AuthorResource, BookResource from yard.api import Api api = Api() api.include( 'books', BookResource ) api.include( 'authors', AuthorResource ) urlpatterns = api.urlpatterns
Main features
Resource and API oriented
Complex API logic
Hypermedia API
JSON serialization
API discovery
Pagination
Metadata
Resource versioning
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yard-framework-2.2.0.tar.gz
(22.0 kB
view hashes)
Built Distribution
Close
Hashes for yard_framework-2.2.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b353e9fb247c3dede3226cf32dd7fc9edbc0c4b6da413ae861aeafe5f168ac6b |
|
MD5 | c33e0cca968ca0bb8d55e05daa1bb0a4 |
|
BLAKE2b-256 | ad27e10f332082b5f851f8838862fb8d3a5a1a81931511d75b14b3d186276eb0 |