New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

djangorestframework-inclusions

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djangorestframework-inclusions

A DRF renderer to side-load relations

  • 1.2.0
  • PyPI
  • Socket score

Maintainers
3

DRF-inclusions

A django-restframework renderer to side-load related resources.

Build status Coverage status Python versions Django versions PyPI

One drawback of RESTful APIs is that you have to make many calls to fetch all the related resources. DRF-inclusions provides a custom renderer allowing you to sideload those in a single, original request.

DRF-inclusions allows you to specify which serializers to use for included resources, and via the query string the client can specify which resources should be included.

Features:

  • arbitrary depth
  • option to include all related resources
  • de-duplication when the same object is found in multiple parent/related objects
  • an effort is made to retrieve related objects in as little DB queries as possible

Installation

pip install djangorestframework-inclusions

Usage

from rest_framework_inclusions.renderer import InclusionJSONRenderer


class MySerializer(...):
    inclusion_serializers = {"some_field": OtherSerializer}


class MyViewSet(...):
    ...
    renderer_classes = (InclusionJSONRenderer,)

See the tests and testapp for advanced usage examples.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc