Skip to content

Conversation

@knyghty
Copy link
Member

@knyghty knyghty commented Aug 22, 2025

Fixes #134

Uses a bit of caching to reduce the number of calls needed when using condition_dict.

For us, this reduces the number of queries in one view (for each step of that view) from nearly 300 to around 17. It's possible it could be improved further but I think this is a dramatic enough of an improvement to be useful on its own.

All the tests pass and I checked my wizards were all working locally. I went for a slightly more realistic test rather than a minimal test, but I can change this if desired.

A simpler solution is to cache the all property. It works quite well, but there are still some extra queries when doing this.

Copy link
Contributor

@claudep claudep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch, it looks good to me, even if some added complexity might be a bug source.

I'd like at least one other approval before pushing it.

@codecov
Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.62%. Comparing base (b31df3c) to head (8b17cdb).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
formtools/wizard/views.py 88.23% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
- Coverage   93.80%   93.62%   -0.19%     
==========================================
  Files          11       11              
  Lines         533      549      +16     
  Branches       86       90       +4     
==========================================
+ Hits          500      514      +14     
- Misses         21       22       +1     
- Partials       12       13       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@knyghty
Copy link
Member Author

knyghty commented Oct 7, 2025

@claudep I did run into an issue testing this with real code. It looks like django-two-factor-auth pops from the form_list and this breaks things. I've added a fix for that here but I'm not sure if manipulating the form list like this is or should be supported. But this should at least avoid breaking existing code. I'm going to try running this in production if it works out okay in testing and let you know how it goes as the performance improvements here are quite necessary for us.

Let me know if you think it should be fixed in another way.

@knyghty
Copy link
Member Author

knyghty commented Oct 23, 2025

The coverage issue above should now be fixed, didn't notice it before, sorry!

FWIW I've been running this in production for a couple of weeks now and seems to be doing well.

@claudep
Copy link
Contributor

claudep commented Oct 26, 2025

Thanks! Could we have a second approval here? Hopefully we are more than 2 people following the activity on this package 😜

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.

multiple get_form_initial calls when condition_dict is used

2 participants