Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formset renders without required id field #1365

Open
awgymer opened this issue Aug 31, 2023 · 2 comments
Open

Formset renders without required id field #1365

awgymer opened this issue Aug 31, 2023 · 2 comments

Comments

@awgymer
Copy link

awgymer commented Aug 31, 2023

  • Package version: 2.0
  • Django version: 4.2.4
  • Python version: 3.11.4
  • Template pack: (Optional) bootstrap5

Description:

Following the docs here I tried to render each form in a formset individually (I am rendering each form in an accordion group and I don't think you can achieve that with FormHelper/Layout?).

However I was getting validation errors:

[{'id': ['This field is required.']}, {'id': ['This field is required.']}, {'id': ['This field is required.']}]

Some googling let to very old issues #143 and #266 and it seems that this only works if you add helper.render_unmentioned_fields.

If this isn't the case and I am doing something wrong then would be good to know what.
If it is the case then would be good to update the docs to make this clear.

@smithdc1
Copy link
Member

Thanks for the comment.

As you are familiar with this issue. What specific changes to the docs do you think would have helped with this issue?

@awgymer
Copy link
Author

awgymer commented Aug 31, 2023

So on further inspection I think it might actually be a ModelForm + Layout issue rather than a formset issue.

Basically if you specify a helper.layout and don't include id field then it won't be rendered which leads to this issue. The only real way to fix this is by adding the render_unmentioned property or by setting the somewhat unclear id field explicitly.

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

No branches or pull requests

2 participants