From ac09cd2967f22b6e8d46f2a573add22a575d2753 Mon Sep 17 00:00:00 2001 From: Diogo Silva <49190578+diogosilva30@users.noreply.github.com> Date: Mon, 18 Mar 2024 01:58:47 +0000 Subject: [PATCH] fix: Fix broke 'get_choices' with restframework 3.15.0 (#1506) --- graphene_django/converter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/graphene_django/converter.py b/graphene_django/converter.py index 121c1de..9d15af2 100644 --- a/graphene_django/converter.py +++ b/graphene_django/converter.py @@ -1,5 +1,4 @@ import inspect -from collections import OrderedDict from functools import partial, singledispatch, wraps from django.db import models @@ -72,8 +71,13 @@ def convert_choice_name(name): def get_choices(choices): converted_names = [] - if isinstance(choices, OrderedDict): + + # In restframework==3.15.0, choices are not passed + # as OrderedDict anymore, so it's safer to check + # for a dict + if isinstance(choices, dict): choices = choices.items() + for value, help_text in choices: if isinstance(help_text, (tuple, list)): yield from get_choices(help_text)