Skip to content

Instantly share code, notes, and snippets.

Avatar

Grant McLean grantm

View GitHub Profile
@ostcar
ostcar / gist:eb78515a41ab41d1755b
Last active May 21, 2021
Adds a _id suffix to PrimaryKeyRelatedField
View gist:eb78515a41ab41d1755b
class IdManyRelatedField(ManyRelatedField):
field_name_suffix = '_ids'
def bind(self, field_name, parent):
self.source = field_name[:-len(self.field_name_suffix)]
super().bind(field_name, parent)
class IdPrimaryKeyRelatedField(PrimaryKeyRelatedField):
"""