From 8043e87b308ff61384b84a2fcde14caef5569209 Mon Sep 17 00:00:00 2001 From: Chris Brantley Date: Wed, 21 Sep 2016 09:56:20 -0500 Subject: [PATCH] Wrap call to key() in list() so it can be indexed In Python 3.4 trying to generate a polymorphic_inlineformset results in a TypeError with the following message: "'KeysView' object does not support indexing". This solves that problem by ensuring that `child_models` is a list, and thus can be referenced by index. --- polymorphic/formsets/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polymorphic/formsets/models.py b/polymorphic/formsets/models.py index e402b4a..998bc6d 100644 --- a/polymorphic/formsets/models.py +++ b/polymorphic/formsets/models.py @@ -180,7 +180,7 @@ class BasePolymorphicModelFormSet(BaseModelFormSet): # Extra forms, cycle between all types # TODO: take the 'extra' value of each child formset into account. total_known = len(self.queryset_data) - child_models = self.child_forms.keys() + child_models = list(self.child_forms.keys()) model = child_models[(i - total_known) % len(child_models)] form_class = self.get_form_class(model)