From a48abd1d3354b382c2d3042492259fd417ed5d04 Mon Sep 17 00:00:00 2001 From: Alisson Patricio Date: Tue, 6 Feb 2024 23:52:44 -0300 Subject: [PATCH] Allows field's choices to be a callable Starting in Django 5 field's choices can also be a callable --- graphene_django/converter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/graphene_django/converter.py b/graphene_django/converter.py index 121c1de..b73135e 100644 --- a/graphene_django/converter.py +++ b/graphene_django/converter.py @@ -1,5 +1,6 @@ import inspect from collections import OrderedDict +from collections.abc import Callable from functools import partial, singledispatch, wraps from django.db import models @@ -72,6 +73,8 @@ def convert_choice_name(name): def get_choices(choices): converted_names = [] + if isinstance(choices, Callable): + choices = choices() if isinstance(choices, OrderedDict): choices = choices.items() for value, help_text in choices: