#29469 closed Bug (fixed)
Misleading makemigrations "App count not be found" error message with nested apps
Reported by: | Matthew Schinckel | Owned by: | oliver |
---|---|---|---|
Component: | Migrations | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have a couple of nested apps, or apps that are not available directly in the top-level namespace.
When you use makemigrations, and pass the full dotted path to this command, the error message is somewhat misleading:
App 'integrations.systems.generic.importers' could not be found. Is it in INSTALLED_APPS?
In this case, I have that exact string in my INSTALLED_APPS, but makemigrations is expecting just the app_label. Perhaps we could improve the error message when dots are detected in the app_label, suggesting how to fix it: or even look at just the last part of the path?
Change History (10)
comment:1 by , 6 years ago
Component: | Uncategorized → Migrations |
---|
comment:2 by , 6 years ago
comment:3 by , 6 years ago
Summary: | Makemigrations provides misleading error message. → Misleading makemigrations "App count not be found" error message with nested apps |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:6 by , 6 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:7 by , 6 years ago
Current code generating that error message is as follows when using makemigraions command.
# Make sure the app they asked for exists app_labels = set(app_labels) bad_app_labels = set() for app_label in app_labels: try: apps.get_app_config(app_label) except LookupError: bad_app_labels.add(app_label) if bad_app_labels: for app_label in bad_app_labels: self.stderr.write("App '%s' could not be found. Is it in INSTALLED_APPS?" % app_label) sys.exit(2)
and below is the part that checks the validity of the app name when using startapp and createproject command
if not name.isidentifier(): raise CommandError( "'{name}' is not a valid {app} name. Please make sure the " "name is a valid identifier.".format( name=name, app=app_or_project, ) )
How about using the code validating app name to current code as follows?
https://github.com/django/django/pull/10052
# Make sure the app they asked for is a valid app name and exist. app_labels = set(app_labels) bad_app_labels = set() for app_label in app_labels: try: apps.get_app_config(app_label) except LookupError: bad_app_labels.add(app_label) if bad_app_labels: for app_label in bad_app_labels: if not app_label.isidentifier(): self.stderr.write( "'%s' is not a valid app name. Please make sure the " "name is a valid identifire."% app_label ) else: self.stderr.write("App '%s' could not be found. Is it in INSTALLED_APPS?" % app_label) sys.exit(2)
comment:9 by , 6 years ago
https://github.com/django/django/pull/10057
I change the target branch to master and add a test.
Maybe you should add an example project?