Skip to content

Commit

Permalink
Added a fallback for model._base_objects to mode.objects when we have…
Browse files Browse the repository at this point in the history
… a non-polymorphic parent fixes #9
  • Loading branch information
foarsitter authored and vdboor committed Nov 18, 2021
1 parent 44fd8b7 commit 346fa6b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion polymorphic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def __init__(self, *args, **kwargs):

def create_accessor_function_for_model(model, accessor_name):
def accessor_function(self):
attr = model._base_objects.get(pk=self.pk)
objects = getattr(model, "_base_objects", model.objects)
attr = objects.get(pk=self.pk)
return attr

return accessor_function
Expand Down

0 comments on commit 346fa6b

Please sign in to comment.