Backport of 5853c87a45 from master. Conflicts: django/core/management/commands/sqlmigrate.py tests/user_commands/tests.py
5853c87a45