mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-12 13:14:23 +03:00
Allows field's choices to be a callable
Starting in Django 5 field's choices can also be a callable
This commit is contained in:
parent
96c09ac439
commit
a48abd1d33
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user