agateblue / django-dynamic-preferences

Dynamic global and instance settings for your django project
https://django-dynamic-preferences.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
350 stars 87 forks source link

ChoicePreference how to store? #238

Closed Bastilla123 closed 2 years ago

Bastilla123 commented 3 years ago

Country_Choices = ( (0, 'Deutschland'), (1, 'Niederlande'), (2, 'Frankreich'), )

@global_preferences_registry.register class client_country(ChoicePreference):

name = 'client_country'
choices = Country_Choices
default = '0'
required = False

Now i want to save this preference:

global_preferences['client_country'] = 1

Exception: This is not a string

global_preferences['client_country'] = '1'

Exception: '1' is not a valid choice

How can i save a ChoicePreference?

felixrindt commented 3 years ago

The docstring for ChoiceField says it only works for string values, so you probably can't use integer values in your choices.