Skip to content

Silence polymorphic.W001 and polymorphic.W002 system checks#14393

Open
Maffooch wants to merge 1 commit intobugfixfrom
polymorphic-error-silence
Open

Silence polymorphic.W001 and polymorphic.W002 system checks#14393
Maffooch wants to merge 1 commit intobugfixfrom
polymorphic-error-silence

Conversation

@Maffooch
Copy link
Contributor

The Question and Answer models intentionally use models.Manager() as their default objects manager instead of PolymorphicManager(). This is a deliberate trade-off introduced in #9574 to fix cascade deletion failures (ForeignKeyViolation on dojo_choiceanswer and ValueError during Product/ProductType deletion) caused by Django's inability to correctly order polymorphic child row deletions before parent row deletions when using PolymorphicManager as the default.

Using models.Manager() as the default ensures Django's collector can walk the full object graph and delete child rows (TextAnswer, ChoiceAnswer) before their parent Answer rows, satisfying FK constraints. A named polymorphic manager is retained on both models for all queryset operations that require polymorphic behavior (used throughout dojo/survey/views.py and dojo/forms.py).

The resulting polymorphic.W001 and polymorphic.W002 warnings are therefore expected and benign — they describe the intentional configuration, not a bug. Silencing them here prevents noise in CI and local development output without masking any real misconfiguration.

The Question and Answer models intentionally use models.Manager() as
their default objects manager instead of PolymorphicManager(). This is
a deliberate trade-off introduced in #9574 to fix cascade deletion
failures (ForeignKeyViolation on dojo_choiceanswer and ValueError during
Product/ProductType deletion) caused by Django's inability to correctly
order polymorphic child row deletions before parent row deletions when
using PolymorphicManager as the default.

Using models.Manager() as the default ensures Django's collector can
walk the full object graph and delete child rows (TextAnswer,
ChoiceAnswer) before their parent Answer rows, satisfying FK constraints.
A named polymorphic manager is retained on both models for all queryset
operations that require polymorphic behavior (used throughout
dojo/survey/views.py and dojo/forms.py).

The resulting polymorphic.W001 and polymorphic.W002 warnings are
therefore expected and benign — they describe the intentional
configuration, not a bug. Silencing them here prevents noise in CI
and local development output without masking any real misconfiguration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Maffooch Maffooch requested a review from mtesauro as a code owner February 26, 2026 00:29
@github-actions github-actions bot added the settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR label Feb 26, 2026
@valentijnscholten valentijnscholten added this to the 2.56.0 milestone Feb 26, 2026
Copy link
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

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

Approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants