jazzband / django-formtools

A set of high-level abstractions for Django forms
https://django-formtools.readthedocs.io
BSD 3-Clause "New" or "Revised" License
794 stars 135 forks source link

Either form_list could be easier to use or docs could be clearer #206

Closed stuaxo closed 2 years ago

stuaxo commented 2 years ago

The examples in the documentation don't seem to set form_list, but all the versions in the tests here do.

TLDR: Either I'm doing something wrong around form_list (in which case the docs could be improved) - or form_list itself could be easier to use.

In detail - I'm trying to write unit tests for a form wizard [1], get_form_list and anything that call it fail - because our form doesn't actually set this, it's only setup in as_view.

This means form_list is still set to None and things fail.

Looking at the code, I'm not sure if I should change the code so we always set form_list as I can't find info on it in the docs.

Without knowing too much about it - it seems like it would be more straightforward if the advice was to always set this, or if it was set elsewhere than as_view, since it seems pretty hard to write tests for form wizards that don't set form_list as a class attribute.

[1] https://github.com/uktrade/tamato/blob/master/measures/views.py#L72 Our form wizard implementation - should I change this so that form_list is always set, after STEPS to make it easier to test?

stuaxo commented 2 years ago

It looks like I should have been using get_initkwargs not as_view to setup initial kwargs.