[2.0.x] Fixed #29091 -- Fixed makemigrations crash if migrations directory doesn't have __init__.py.
Regression inaadd3aeb2b
. Backport of0a37ea56d0
from master
This commit is contained in:
parent
55e16f25e9
commit
834843ca4f
|
@ -48,7 +48,7 @@ class MigrationQuestioner:
|
||||||
elif hasattr(migrations_module, "__path__"):
|
elif hasattr(migrations_module, "__path__"):
|
||||||
if len(migrations_module.__path__) > 1:
|
if len(migrations_module.__path__) > 1:
|
||||||
return False
|
return False
|
||||||
filenames = os.listdir(migrations_module.__path__[0])
|
filenames = os.listdir(list(migrations_module.__path__)[0])
|
||||||
return not any(x.endswith(".py") for x in filenames if x != "__init__.py")
|
return not any(x.endswith(".py") for x in filenames if x != "__init__.py")
|
||||||
|
|
||||||
def ask_not_null_addition(self, field_name, model_name):
|
def ask_not_null_addition(self, field_name, model_name):
|
||||||
|
|
|
@ -24,3 +24,6 @@ Bugfixes
|
||||||
* Fixed a regression where ``contrib.auth.authenticate()`` crashes if an
|
* Fixed a regression where ``contrib.auth.authenticate()`` crashes if an
|
||||||
authentication backend doesn't accept ``request`` and a later one does
|
authentication backend doesn't accept ``request`` and a later one does
|
||||||
(:ticket:`29071`).
|
(:ticket:`29071`).
|
||||||
|
|
||||||
|
* Fixed a regression where ``makemigrations`` crashes if a migrations directory
|
||||||
|
doesn't have an ``__init__.py`` file (:ticket:`29091`).
|
||||||
|
|
|
@ -853,6 +853,13 @@ class MakeMigrationsTests(MigrationTestBase):
|
||||||
call_command("makemigrations", stdout=out)
|
call_command("makemigrations", stdout=out)
|
||||||
self.assertIn("0001_initial.py", out.getvalue())
|
self.assertIn("0001_initial.py", out.getvalue())
|
||||||
|
|
||||||
|
def test_makemigrations_no_init(self):
|
||||||
|
"""Migration directories without an __init__.py file are allowed."""
|
||||||
|
out = io.StringIO()
|
||||||
|
with self.temporary_migration_module(module='migrations.test_migrations_no_init'):
|
||||||
|
call_command('makemigrations', stdout=out)
|
||||||
|
self.assertIn('0001_initial.py', out.getvalue())
|
||||||
|
|
||||||
def test_makemigrations_migrations_announce(self):
|
def test_makemigrations_migrations_announce(self):
|
||||||
"""
|
"""
|
||||||
makemigrations announces the migration at the default verbosity level.
|
makemigrations announces the migration at the default verbosity level.
|
||||||
|
|
Loading…
Reference in New Issue