Skip to content

Instantly share code, notes, and snippets.

View vishalp-perpetualny's full-sized avatar

vishalp-perpetualny

View GitHub Profile
@vishalp-perpetualny
vishalp-perpetualny / create_update_mixin.py
Last active May 31, 2022 11:28
neseted create mixin
from rest_framework.utils import model_meta
import copy
class SimplifiedNestedCreateMixin:
"""
Serializer with helper methods to handle nested crud.
usage:
declare a nesting map which is a dictionary of dictionary
- 'related_name_on_children_field': #'1-M or 1-1 models as key,
- 'serializer' : the serializer instance responsible for handling the create / update

Keybase proof

I hereby claim:

  • I am vishalp-perpetualny on github.
  • I am notvishal (https://keybase.io/notvishal) on keybase.
  • I have a public key ASCI1uWkvziAdWv-rL6Q1CPtphzAvZPN4vo0mmtTrjxLwAo

To claim this, I am signing this object: