Extension for Django Rest Framework to enable simple sideloading
Project description
Extention for Django Rest Framework to enable simple sidloading
Documentation
The full documentation is at https://drf-sideloading.readthedocs.io.
Quickstart
Install drf-sideloading:
pip install drf-sideloading
Import Mixin SideloadableRelationsMixin:
from drf_sideloading.mixins import SideloadableRelationsMixin
Include mixin in view, define serializers dict sideloadable_relations and base_model_name
class ProductViewSet(SideloadableRelationsMixin, viewsets.ModelViewSet):
"""
A simple ViewSet for viewing and editing products.
"""
queryset = Product.objects.all()
serializer_class = ProductSerializer
base_model_name = 'product'
sideloadable_relations = {
'product': ProductSerializer,
'category': CategorySerializer,
'supplier': SupplierSerializer,
'partner': PartnerSerializer
}
Add extra parameter and define comma separated relations:
GET http://example.com/product/?sideload=category,partner,supplier
Features
TODO
fix documentation
improve coverage
python3 support
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Credits
Tools used in rendering this package:
History
0.1.0 (2017-07-20)
First release on PyPI.
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
Built Distribution
Hashes for drf_sideloading-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88704e92775c876d4f9f3ae257222c31656ed6ccfc5f83e7c7176a179d2ec30b |
|
MD5 | b63d417c0c64493f43ab7213e3513f03 |
|
BLAKE2b-256 | 3b919134042efe9665cf7ad1b5714dc8f2e9791dde85100dcb8824b67d07e1c8 |