Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BindingDict should support standard dict-functions #2135 #2163

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions rest_framework/utils/serializer_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,20 @@ def keys(self):

def values(self):
return self.fields.values()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above line has whitespace in it that needs to be removed.

def pop(self, field_name, default=None):
if field_name in self.fields.keys():
popped = self.fields[field_name]
del self.fields[field_name]
return popped
else:
return default

def get(self, field_name, default=None):
if field_name in self.fields.keys():
return self.fields[field_name]
else:
return default

def __len__(self):
return len(self.fields())