Acessing optional serialized fields yields `rest_framework.fields.empty`.
wkrueger opened this issue · 2 comments
wkrueger commented
@dataclass
class SomeClass:
maybeDog: Optional[Dog]
instance = getInst() # lets say getInst() serializes an input with that dataclass, gets value through validated_data
if instance.maybeDog: # this is always truthy, because when maybeDog is absent its value is acessed as field.empty
print('bark')