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

render_field function doesn't work with formset #1169

Open
wail-asad opened this issue Jun 8, 2021 · 4 comments
Open

render_field function doesn't work with formset #1169

wail-asad opened this issue Jun 8, 2021 · 4 comments

Comments

@wail-asad
Copy link

wail-asad commented Jun 8, 2021

  • Package version:1.11.0
  • Django version:3.2.0
  • Python version:3.7.6

Description:

I used Django render_field method to return a form design of formset.
I know that there a method to get tabular design of form set by using self.helper.template='crispy-tabuler-page' but this method gives all fields of formsets and ignore all design in self.helper.layout
so I used render_field method to get html design of formset in the view.
the problem is
Django Version: 3.2 Exception Type: TypeError Exception Value: list indices must be integers or slices, not str Exception Location: C:\0ERPFlex\ERPFlex_venv\lib\site-packages\django\forms\formsets.py, line 96, in __getitem__ Python Executable: C:\0ERPFlex\ERPFlex_venv\Scripts\python.exe Python Version: 3.7.6

I make this fixed in the method render_fields :
if hasattr(form,'forms'): form=form.forms[0]

and the problem was solved but I want a this fixed in the next version in render_fields

@smithdc1
Copy link
Member

smithdc1 commented Jun 8, 2021

I'm not sure I understand your issue.

Happy to review a Pull Request with tests showing the behaviour you desire would be welcomed. 👍

@wail-asad
Copy link
Author

@smithdc1 could you open a branch with these issue to make pull request I want also to make Layout for formset

@smithdc1
Copy link
Member

smithdc1 commented Jun 8, 2021

Please send the pull request to the main branch of this repository.

@wail-asad
Copy link
Author

@smithdc1 let me know if I can make push for a tabular formset design with js file for its actions.

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