Skip to content

Commit

Permalink
Return self if called on the class instead of instance to not error o…
Browse files Browse the repository at this point in the history
…ut in metaprogramming in internals of djangorestframework.
  • Loading branch information
hwalinga committed Apr 25, 2021
1 parent df66df4 commit a8b7cb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Authors
- Hamish Downer
- Hanyin Zhang
- Hernan Esteves (`sevetseh28 <https://github.com/sevetseh28>`_)
- Hielke Walinga (`hwalinga <https://github.com/hwalinga>`_)
- Jack Cushman (`jcushman <https://github.com/jcushman>`_)
- James Muranga (`jamesmura <https://github.com/jamesmura>`_)
- James Pulec
Expand Down
2 changes: 2 additions & 0 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ def __init__(self, model, fields_included):
self.fields_included = fields_included

def __get__(self, instance, owner):
if instance is None:
return self
values = {f.attname: getattr(instance, f.attname) for f in self.fields_included}
return self.model(**values)

Expand Down

0 comments on commit a8b7cb1

Please sign in to comment.