﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37224	Migration questioner complains about missing defaults for fields in unmanaged models	Jacob Walls	Vishy	"Since the improvement to tracking unmanaged model field alterations in #35813, the migration questioner (the interactive prompt) will now complain on missing defaults for altered fields.

In [https://github.com/django/django/pull/18651#issuecomment-5007220658 a post-merge comment] I suggested we could short-circuit in the questioner for unmanaged models, since if the model is ''unmanaged'' then it's not strictly true that it's ""impossible"" to add such fields, especially for unmanaged models that just shadow database views.

Sarah had a [https://github.com/django/django/pull/18651#pullrequestreview-4651959612 similar observation] before merge.

With this patch, I no longer needed to enter dummy values in the prompt:


{{{#!diff
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index 0d0010f868..b9eff8ee2b 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -1163,6 +1163,7 @@ class MigrationAutodetector:
             or (field.blank and field.empty_strings_allowed)
             or (isinstance(field, time_fields) and field.auto_now)
             or (isinstance(field, auto_fields))
+            or not self.to_state.apps.get_model(app_label, model_name)._meta.managed
         )
         if not preserve_default:
             field = field.clone()
@@ -1331,6 +1332,7 @@ class MigrationAutodetector:
                         and not new_field.has_default()
                         and not new_field.has_db_default()
                         and not new_field.many_to_many
+                        and self.to_state.apps.get_model(app_label, model_name)._meta.managed
                     ):
                         field = new_field.clone()
                         new_default = self.questioner.ask_not_null_alteration(
}}}

There would be a few other places to check to see where else we can short-circuit. What do folks think?"	Bug	assigned	Migrations	dev	Release blocker			Sarah Boyce Hanny G	Accepted	0	0	0	0	0	0
