Skip to content

Conversation

bctiemann
Copy link
Contributor

Fixes: #42

Adds logic at the view level to ensure the multiobject form fields are populated with values specified as default (for multiobject fields, these are specified as a list, e.g. [21, 24]).

Screenshot 2025-09-09 at 8 18 14 PM

Note that this functionality is not entirely in line with the behavior for single-object fields, in which a single ID can be specified as a default value and the related object of that ID will automatically be assigned to a new model instance of a custom object created programmatically, i.e. model(). M2M fields such as this need to be populated after instance creation. This should not be unexpected behavior however, because an instance created with model() is not yet persisted and has no ID, so there should be no way to create M2M relations at that stage in its lifecycle.

@bctiemann bctiemann requested a review from arthanson September 10, 2025 00:24
@arthanson arthanson merged commit 1d4ef5a into main Sep 10, 2025
5 checks passed
@bctiemann bctiemann deleted the 42-multiobject-default-values branch September 19, 2025 17:26
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.

Default value should be auto-populated for multi-object fields

2 participants