New django admin error on CharField with Choices

Hi all,

I have a new error - the Admin screen is rejecting what appear to be valid strings. It began around the time I updated my packages but it was only from a previous 4.1 to 4.1.10. When I load the shell and use Things._meta.get_field(“labels”).choices, I can see the list of tuples I expect:
[(‘label1’, ‘label1’),
(‘label2’, ‘label2’)]

I could submit pages, but the backend would respond with “please correct this entry, is not a valid choice”

The “choices” list was being generated by a function that would create it at import time, just ahead of the model that used the choices. This made some sense for the job it was doing though I don’t see it recommended (and it had the bad quality of confusing the migrations part of the ORM into applying the choice limits as a new migration every time a migration occurred.)

The error is gone after I changed to the more normal hard-coded list. But I don’t really understand what started going wrong in the function-based version and I would like to. Also I had trouble getting to the bottom of this - is there a quick clean way to get more visibility of the content of admin pages? It would be easier if it had just thrown a stacktrace, but the admin was sure it was correctly rejecting invalid entries and I couldn’t think of a good way to interrogate.

It seems the error occurred due to choices that you might have given to one of the Charfield in models, you might have defined the choices which you have assigned to your charfield you can inspect your choices within browser it will give you select input within the form and you can check the value of the particular options that will be rendered there.

No, the in-browser validation would prevent submit events posting to the backend, but they go ahead, and when I inspected the field it didn’t have validation values (its weird that its widget is a free textfield rather than a select box, given that you can’t mis-type in it; that might be something to check)

well if you can share the related model, it might help :crossed_fingers: