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

Adding a formset to a form a la django dynamic formsets #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MikeAmy
Copy link

@MikeAmy MikeAmy commented Jul 15, 2013

Not sure where to send this for a pull request. webtest seems django-agnostic, so here seemed best.

We (I work with Julien Aubert) had a test where there was javascript in the page to add a formset form with some data. In the browser this was done with javascript, using the django dynamic formset mechanism. This wasn't reproducible in webtest due to it not handling the javascript, so this code does the same as the javascript to enable the test.

No problem if you want to decline the request, just offering it in in case it might be useful for those in the same situation.

@kmike
Copy link
Member

kmike commented Jul 16, 2013

Thanks, this looks useful indeed!

I don't want to merge it right now because of monkey-patching. Also, some tests would be great - the code is not trivial.

Maybe create a PR to Webtest for making Form class an attribute of TestResponse? This will allow us to provide a custom Form class with django-specific goodies, and it looks a simple enough change.

The feature will be enabled only with newer WebTest versions then (older versions will be ignoring our custom form class), but I think that's fine.

@ranelpadon
Copy link

ranelpadon commented Jun 8, 2018

We have similar use case. We wanted to test a Django view involving a formset. It would be good if Django WebTest has support for dynamic/extra formset. We ended up implementing the suggestion below. :)

https://stackoverflow.com/questions/22708511/can-i-add-non-existing-field-to-form-with-webtest#answer-23877996

@gawel
Copy link
Member

gawel commented Jun 9, 2018

Maybe Form.add_field() can be added to webtest itself.

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

Successfully merging this pull request may close these issues.

None yet

4 participants