Resolve auto-created models in `apps.get_model()` #3791
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.35) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 164 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.305
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3791"
general
weight: 0.35
UnknownPlatypus
Fixes #3769.
apps.get_model("<app>.<Name>")fails withCould not match lazy reference with any modelfor the implicit through model of a many-to-many field, becauseDjangoContext.all_registered_model_classescollects models withapps_registry.get_models(), and Django's auto-created models are not part of that list. Django itself resolves them inApps.get_model().The property now asks for
include_auto_created=True, include_swapped=True, the same flags thatDjangoContext.model_modulesalready passes.Test:
tests/assert_type/apps/test_registry/models.pygains a model with aManyToManyFieldand resolves its through model both by label and by(app_label, model_name). Without the change mypy reports twoCould not match lazy reference with any modelerrors; with it the file type-checks andthrough.objectsis typed.Verification (
mypy 2.4.1,django 6.1.2):mypy tests/assert_type: 149 files, no issuesmypy ext scripts mypy_django_plugin(the repo'smypy-self): 43 files, no issuesruff checkandruff format --checkon both changed filespytest tests/typecheck) need a Linux environment here; they fail on encoding/GIS issues on my machine, before and after the changeI prepared this with an AI coding assistant and reviewed the diff myself.