mirror of
				https://github.com/django/django.git
				synced 2025-11-03 21:25:09 +00:00 
			
		
		
		
	Fixed #29091 -- Fixed makemigrations crash if migrations directory doesn't have __init__.py.
Regression in aadd3aeb2b.
			
			
This commit is contained in:
		
							parent
							
								
									de59132afc
								
							
						
					
					
						commit
						0a37ea56d0
					
				
					 4 changed files with 11 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -48,7 +48,7 @@ class MigrationQuestioner:
 | 
			
		|||
            elif hasattr(migrations_module, "__path__"):
 | 
			
		||||
                if len(migrations_module.__path__) > 1:
 | 
			
		||||
                    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")
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
  authentication backend doesn't accept ``request`` and a later one does
 | 
			
		||||
  (: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)
 | 
			
		||||
        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):
 | 
			
		||||
        """
 | 
			
		||||
        makemigrations announces the migration at the default verbosity level.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										0
									
								
								tests/migrations/test_migrations_no_init/.gitkeep
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/migrations/test_migrations_no_init/.gitkeep
									
										
									
									
									
										Normal file
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue