Closed parrotmac closed 4 years ago
This change adds support to serializing to a nested proto message by defining a dictionary within pb_2_dj_field_map. For example:
pb_2_dj_field_map
syntax = "proto3"; message Spreads { bool mayo = 0; bool mustard = 1; bool aioli = 2; } message Sandwich { int32 toastLevel = 1; Spreads spreads = 2; };
class Sandwich(models.Model): pb_model = sandwich_pb2.Sandwich pb_2_dj_field_map = { "toastLevel": "toastLevel", "spreads": { "mayo": "include_mayo", "mustard": "include_mustard", "aioli": "include_aioli", }, } toast_level = models.IntegerField(default=3) include_mayo = models.BooleanField(default=False) include_mustard = models.BooleanField(default=False) include_aioli = models.BooleanField(default=True)
Still working on from_pb and tests.
from_pb
This also includes some light formatting, but happy to change that to any preferences.
THANK YOU!
This change adds support to serializing to a nested proto message by defining a dictionary within
pb_2_dj_field_map
. For example:Still working on
from_pb
and tests.This also includes some light formatting, but happy to change that to any preferences.