Opened 3 years ago

Closed 3 years ago

#32247 closed Cleanup/optimization (invalid)

"App does not have migrations" message could be more helpful

Reported by: berzi Owned by:
Component: Error reporting Version: 3.1
Severity: Normal Keywords: documentation, errors, error messages
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

It has happened to me and probably many many others several times that running

manage.py migrate SOME_APP

would yield an error like

CommandError: App 'SOME_APP' does not have migrations.

all while a migrations folder with migrations *does exist* in the specified app. It is often the case that the cause of the issue is simply that the __init__.py file is missing from the directory, but that is not at all apparent. Even running

manage.py showmigrations SOME_APP

is unhelpful and unless the programmer is specifically aware of this potential issue (and even then it's easy to forget) the problem can be confusing to solve.

I propose a simple change of the error message to:

CommandError: No migration detected for app 'SOME_APP'. Is an '__init__.py' file present in the 'migrations/' directory?

Or something to the same effect.

Change History (1)

in reply to:  description comment:1 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed
Type: UncategorizedCleanup/optimization
UI/UX: unset

Replying to berzi:

CommandError: App 'SOME_APP' does not have migrations.

all while a migrations folder with migrations *does exist* in the specified app. It is often the case that the cause of the issue is simply that the __init__.py file is missing from the directory, but that is not at all apparent.

This message doesn't say anything about migrations directory but about migrations module. Python packages without an __init__.py file ("namespace packages") are not supported, see #30300.

I propose a simple change of the error message to:

CommandError: No migration detected for app 'SOME_APP'. Is an '__init__.py' file present in the 'migrations/' directory?

__init__.py files are required in most directories I don't see any specific reason to highlight them here. It's also automatically created when you use startapp, which I recommend.

Note: See TracTickets for help on using tickets.
Back to Top