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.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bdcb4f87b3c2379b4f09c735a2ce73a026405a95ebbd72ac9536bd97f4ad567 |
|
MD5 | cf159cdded31ce5e06d04f5093d6bb6b |
|
BLAKE2b-256 | 4ce5263a7eb7e958a3da53b7f99fc87fad003073b3c9192ef69ce9034f59ffe7 |