Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Field 'id' expected a number but got ['99']. #79

Open
gassan opened this issue Jun 10, 2020 · 3 comments
Open

Field 'id' expected a number but got ['99']. #79

gassan opened this issue Jun 10, 2020 · 3 comments
Labels

Comments

@gassan
Copy link

gassan commented Jun 10, 2020

If I have some ChoiceWidget on the formset. So prepares the function self.empty_form[field_name].field.widget.format_value(self.empty_form[field_name].value())
an array [99] for that value. Here are for example 2 Choice fields: food' and unit: {'food': ['99'], 'qty': '6', 'unit': ['2'], 'block': '0', 'extra': '', 'id': '82', 'ORDER': '1', 'DELETE': None}.
That error occurs when the form is sent without having edited anything

@kaedroho kaedroho added the bug label Jul 28, 2020
@noampolak
Copy link

I have the same issue
my workaround was to edit the package:
in the file edit_handlers.py I replaced line
edit_handlers.py
obj = model.objects.filter(pk=value).first()
to:

try: obj = model.objects.filter(pk=value).first() except: obj = model.objects.filter(pk=int(value[0])).first()

I had to add the 2 options because of compatibility with my old objects

@gassan
Copy link
Author

gassan commented Dec 19, 2020

I have forked it and changed 2 lines of code.
https://github.com/gassan/wagtail-condensedinlinepanel

@nusol-sc
Copy link

nusol-sc commented Apr 2, 2021

My workaround has been to reverse the orders of the assignments when building the fields list in both 'forms' and 'emptyForm'. It may not be the best fix, but it seems to work fine for now:

Before

field_name: form[field_name].field.widget.format_value(form[field_name].value()) or form[field_name].value()
field_name: self.empty_form[field_name].field.widget.format_value(self.empty_form[field_name].value()) or self.empty_form[field_name].value()

After

field_name: form[field_name].value() or form[field_name].field.widget.format_value(form[field_name].value())
field_name: self.empty_form[field_name].value() or self.empty_form[field_name].field.widget.format_value(self.empty_form[field_name].value())

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants