-
Notifications
You must be signed in to change notification settings - Fork 65
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
Default to no formsets when 'formsets' / 'exclude_formsets' not specified #158
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This then makes it possible to specify these in a nested 'formsets' dict in ClusterForm.Meta.
…lt in no formsets, rather than all formsets
gasman
added a commit
to gasman/wagtail
that referenced
this pull request
Mar 11, 2022
…s semantics django-modelcluster 6.0 is planned to include wagtail/django-modelcluster#158, which changes the semantics of formsets/exclude_formsets so that a ClusterForm that specifies neither of them will have no formsets defined, rather than formsets for all child relations. (This corrects an implementation wart in the upcoming EditHandler refactor.) This doesn't affect Wagtail for the most part, because EditHandler passes an explicit formsets option - but nested InlinePanels currently rely on the old behaviour, because modelcluster <=5 provides no way to pass the inner panel's formset definition inside the outer one. We fix this by adding the necessary 'formsets' key introduced in wagtail/django-modelcluster#158.
gasman
added a commit
to gasman/wagtail
that referenced
this pull request
Mar 11, 2022
…s semantics django-modelcluster 6.0 is planned to include wagtail/django-modelcluster#158, which changes the semantics of formsets/exclude_formsets so that a ClusterForm that specifies neither of them will have no formsets defined, rather than formsets for all child relations. (This corrects an implementation wart in the upcoming EditHandler refactor.) This doesn't affect Wagtail for the most part, because EditHandler passes an explicit formsets option - but nested InlinePanels currently rely on the old behaviour, because modelcluster <=5 provides no way to pass the inner panel's formset definition inside the outer one. We fix this by adding the necessary 'formsets' key introduced in wagtail/django-modelcluster#158.
gasman
added a commit
to gasman/wagtail
that referenced
this pull request
Mar 11, 2022
…s semantics django-modelcluster 6.0 is planned to include wagtail/django-modelcluster#158, which changes the semantics of formsets/exclude_formsets so that a ClusterForm that specifies neither of them will have no formsets defined, rather than formsets for all child relations. (This corrects an implementation wart in the upcoming EditHandler refactor.) This doesn't affect Wagtail for the most part, because EditHandler passes an explicit formsets option - but nested InlinePanels currently rely on the old behaviour, because modelcluster <=5 provides no way to pass the inner panel's formset definition inside the outer one. We fix this by adding the necessary 'formsets' key introduced in wagtail/django-modelcluster#158.
gasman
added a commit
to gasman/wagtail
that referenced
this pull request
Mar 11, 2022
…s semantics django-modelcluster 6.0 is planned to include wagtail/django-modelcluster#158, which changes the semantics of formsets/exclude_formsets so that a ClusterForm that specifies neither of them will have no formsets defined, rather than formsets for all child relations. (This corrects an implementation wart in the upcoming EditHandler refactor.) This doesn't affect Wagtail for the most part, because EditHandler passes an explicit formsets option - but nested InlinePanels currently rely on the old behaviour, because modelcluster <=5 provides no way to pass the inner panel's formset definition inside the outer one. We fix this by adding the necessary 'formsets' key introduced in wagtail/django-modelcluster#158.
gasman
added a commit
to gasman/wagtail
that referenced
this pull request
Mar 14, 2022
…s semantics django-modelcluster 6.0 includes wagtail/django-modelcluster#158, which changes the semantics of formsets/exclude_formsets so that a ClusterForm that specifies neither of them will have no formsets defined, rather than formsets for all child relations. (This corrects an implementation wart in the upcoming EditHandler refactor.) This doesn't affect Wagtail for the most part, because EditHandler passes an explicit formsets option - but nested InlinePanels currently rely on the old behaviour, because modelcluster <=5 provides no way to pass the inner panel's formset definition inside the outer one. We fix this by adding the necessary 'formsets' key introduced in wagtail/django-modelcluster#158.
gasman
added a commit
to gasman/wagtail
that referenced
this pull request
Mar 14, 2022
…s semantics django-modelcluster 6.0 includes wagtail/django-modelcluster#158, which changes the semantics of formsets/exclude_formsets so that a ClusterForm that specifies neither of them will have no formsets defined, rather than formsets for all child relations. (This corrects an implementation wart in the upcoming EditHandler refactor.) This doesn't affect Wagtail for the most part, because EditHandler passes an explicit formsets option - but nested InlinePanels currently rely on the old behaviour, because modelcluster <=5 provides no way to pass the inner panel's formset definition inside the outer one. We fix this by adding the necessary 'formsets' key introduced in wagtail/django-modelcluster#158.
gasman
added a commit
to gasman/wagtail
that referenced
this pull request
Mar 14, 2022
…s semantics django-modelcluster 6.0 includes wagtail/django-modelcluster#158, which changes the semantics of formsets/exclude_formsets so that a ClusterForm that specifies neither of them will have no formsets defined, rather than formsets for all child relations. (This corrects an implementation wart in the upcoming EditHandler refactor.) This doesn't affect Wagtail for the most part, because EditHandler passes an explicit formsets option - but nested InlinePanels currently rely on the old behaviour, because modelcluster <=5 provides no way to pass the inner panel's formset definition inside the outer one. We fix this by adding the necessary 'formsets' key introduced in wagtail/django-modelcluster#158.
gasman
added a commit
to wagtail/wagtail
that referenced
this pull request
Mar 16, 2022
…s semantics django-modelcluster 6.0 includes wagtail/django-modelcluster#158, which changes the semantics of formsets/exclude_formsets so that a ClusterForm that specifies neither of them will have no formsets defined, rather than formsets for all child relations. (This corrects an implementation wart in the upcoming EditHandler refactor.) This doesn't affect Wagtail for the most part, because EditHandler passes an explicit formsets option - but nested InlinePanels currently rely on the old behaviour, because modelcluster <=5 provides no way to pass the inner panel's formset definition inside the outer one. We fix this by adding the necessary 'formsets' key introduced in wagtail/django-modelcluster#158.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, if both
formsets
andexclude_formsets
were left unspecified in theclass Meta
of a ClusterForm, it would default to creating formsets for all child relations defined on the model - this was done for consistency with the pre-Django-1.8 behaviour of ModelForm'sfields
/exclude
options, and was never changed to match the newer Django behaviour. This PR changes this to creating no child formsets instead. This way, a ClusterForm omitting these options is functionally equivalent to a ModelForm with the same set of Meta options.As a pre-requisite to this, we need to implement the ability to pass nested
formsets
definitions to be handled by childformset_factory, which was previously left out of #106:Without this, the only way to build multi-level formsets was to leave the inner ClusterForm to automatically 'discover' its child formsets
This is a breaking change and will need an update in Wagtail - standard EditHandler/InlinePanel-based forms are OK (because they specify the formsets explicitly via the
EditHandler.required_formsets
method), but nested InlinePanels now need to propagate theirformsets
arguments up the tree via this newly implemented mechanism.