#23407 closed Cleanup/optimization (fixed)

makemigrations doesn't use --noinput

Reported by: bmispelon Owned by: knbk
Component: Migrations Version: 1.7
Severity: Normal Keywords: sprint ams2015
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


#22862 added the --noinput to the makemigrations command but only when using --merge.

It seems to me that it would be a useful addition to the plain makemigrations too and could work like this:

  • If the migrations can be created without user input, create it
  • If not, raise an error.

I tried changing the code to use MigrationQuestioner instead of InteractiveMigrationQuestioner but it seems that this just creates a migration with default=None which might not be what you want.

Implementing a new questioner object like this seems to work in my limited testcase:

class NonInteractiveQuestioner(MigrationQuestioner):
    def ask_not_null_addition(self, field_name, model_name):
        raise NotImplementedError

    def ask_rename(self, model_name, old_name, new_name, field_instance):
        raise NotImplementedError

    def ask_rename_model(self, old_model_state, new_model_state):
        raise NotImplementedError

    def ask_merge(self, app_label):
        raise NotImplementedError

Change History (12)

comment:1 Changed 20 months ago by bmispelon

I'll also note that the current documentation for makemigrations [1] is incorrect since it states:

The --noinput option may be provided to suppress all user prompts.

Which is incorrect.

[1] https://docs.djangoproject.com/en/1.7/ref/django-admin/#django-admin-makemigrations

comment:2 Changed 20 months ago by timgraham

  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

If we don't choose to backport the fix to 1.7, we should correct the documentation.

comment:3 Changed 20 months ago by andrewgodwin

Agree that implementing a new questioner is the best way, though I think some of the questions we can give sensible answers to (e.g. rename, rename_model should probably just be False as rename detection is not guaranteed anyway)

comment:4 Changed 19 months ago by Tim Graham <timograham@…>

In 450a61600407d7320b85b75b441ce67b199da68b:

Corrected --noinput docs for makemigrations; refs #23407.

comment:5 Changed 19 months ago by Tim Graham <timograham@…>

In 40e5eb4114e66dfaacea162fc9f39c0618dcfad9:

[1.7.x] Corrected --noinput docs for makemigrations; refs #23407.

Backport of 450a616004 from master

comment:6 Changed 19 months ago by timgraham

  • Severity changed from Release blocker to Normal

comment:7 Changed 15 months ago by karyon

there is also "manage.py makemigrations --help" which tells the user

"--noinput             Tells Django to NOT prompt the user for input of any kind."

comment:8 Changed 14 months ago by MarkusH

  • Easy pickings set
  • Keywords sprint ams2015 added

comment:9 Changed 14 months ago by knbk

  • Owner changed from nobody to knbk
  • Status changed from new to assigned

comment:11 Changed 14 months ago by MarkusH

  • Triage Stage changed from Accepted to Ready for checkin

comment:12 Changed 14 months ago by Markus Holtermann <info@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In e272904ff7cc4d138e316ba2e7811666053860a4:

Fixed #23407 -- Extended coverage of makemigrations --noinput option.

Changed --noinput option in makemigrations to suppress all user prompts,
not just when combined with --merge.

Note: See TracTickets for help on using tickets.
Back to Top