Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This will set initial values for visible bulk-add form fields from query args.
Fixes:
#1778
This is a simple fix to allow bulk-addition of addresses to receive initial values set in the single-address-addition form, which are already passed as query args in the URL.
The approach I took is just to loop through the form's visible Meta fields, and build a dict of initial form field values from query args that match field names. (initial vals described here):
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#providing-initial-values
Query args that don't match field names are ignored since we loop on meta fields, not the query args, and Django quietly ignores invalid initial values.
There are alternate approaches to comparing the fields but they seemed like micro optimizations and slightly less easy to read: