You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MultipleChoiceSelect is a custom subclass of django's MultipleChoiceField, and overrides the to_python(...) and prepare_value(...) methods, to convert from a list of ints (or strings of ints) to a list of enums, and vice versa.
In constance 3.x, this worked without problem. If I accessed config.CHORD_CDM_PLATFORMS I got a list of Platform enums back.
In constance 4.x, if I access config.CHORD_CDM_PLATFORMS, I get a list of integers, which further in the code leads to all kinds of errors, because the usual properties that this enum has (e.g. .values, .names) do not exist.
I tried registering a new custom type (like in codecs.py), but I could not figure out how to link that to our 'platform_select' field. Whatever I do, constance puts a "default" value as the "discriminator" string in the database, so the new type was never linked to our 'platform_select' type.
Is there a way to make sure that this works again?
To me the most obvious way would be to "fix" constance so that it calls <custom_field>.to_python(...) on config value access, and <custom_field>.prepare_value(...) when setting a config value. But maybe that won't work, or another way is better?
I really hope a solution is somehow possible.
Thanks!
Vincent.
The text was updated successfully, but these errors were encountered:
I hope someone more knowledgeable than me about constance development is reading this?
If there is no hope to work together towards a solution for this, please let me know. No hard feelings, but we will then have to look for an alternative to Constance, because this is currently holding back the upgrade and that is sooner or later going to bite us.
Uh oh!
There was an error while loading. Please reload this page.
We have some constance items that are lists of enums.
We defined these with a custom type like this:
And
MultipleChoiceSelect is a custom subclass of django's MultipleChoiceField, and overrides the
to_python(...)
andprepare_value(...)
methods, to convert from a list of ints (or strings of ints) to a list of enums, and vice versa.In constance 3.x, this worked without problem. If I accessed config.CHORD_CDM_PLATFORMS I got a list of
Platform
enums back.In constance 4.x, if I access config.CHORD_CDM_PLATFORMS, I get a list of integers, which further in the code leads to all kinds of errors, because the usual properties that this enum has (e.g.
.values
,.names
) do not exist.I tried registering a new custom type (like in codecs.py), but I could not figure out how to link that to our 'platform_select' field. Whatever I do, constance puts a "default" value as the "discriminator" string in the database, so the new type was never linked to our 'platform_select' type.
Is there a way to make sure that this works again?
To me the most obvious way would be to "fix" constance so that it calls
<custom_field>.to_python(...)
on config value access, and<custom_field>.prepare_value(...)
when setting a config value. But maybe that won't work, or another way is better?I really hope a solution is somehow possible.
Thanks!
Vincent.
The text was updated successfully, but these errors were encountered: