Skip to content

Instantly share code, notes, and snippets.

View grantm's full-sized avatar

Grant McLean grantm

View GitHub Profile
@ostcar
ostcar / gist:eb78515a41ab41d1755b
Last active October 28, 2023 10:34
Adds a _id suffix to PrimaryKeyRelatedField
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):
"""