Closed Bastilla123 closed 2 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?
The docstring for ChoiceField says it only works for string values, so you probably can't use integer values in your choices.
Country_Choices = ( (0, 'Deutschland'), (1, 'Niederlande'), (2, 'Frankreich'), )
@global_preferences_registry.register class client_country(ChoicePreference):
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?