﻿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
28913	If MIGRATIONS_MODULES has a missing top-level package, proper error message is not displayed	oTree-org	Sanket Saurav	"The following code in django.db.migrations.writer doesn't handle the case where the top-level package doesn't exist. When existing_dirs only has one element left, it will be popped, so existing_dirs is empty. Then import_module() will be passed an empty string, which doesn't raise ImportError, but rather ""ValueError: Empty module name"". Because ValueError is not caught, the ""raise ValueError"" with the helpful error message is not displayed.

{{{
        # In case of using MIGRATION_MODULES setting and the custom package
        # doesn't exist, create one, starting from an existing package
        existing_dirs, missing_dirs = migrations_package_name.split("".""), []
        while existing_dirs:
            missing_dirs.insert(0, existing_dirs.pop(-1))
            try:
                base_module = import_module(""."".join(existing_dirs))
            except ImportError:
                continue
            else:
                try:
                    base_dir = module_dir(base_module)
                except ValueError:
                    continue
                else:
                    break
        else:
            raise ValueError(
                ""Could not locate an appropriate location to create ""
                ""migrations package %s. Make sure the toplevel ""
                ""package exists and can be imported."" %
                migrations_package_name)
}}}
"	Bug	closed	Migrations	1.11	Normal	fixed		Sanket Saurav	Accepted	1	0	0	0	0	0
