[Django] #32247: "App does not have migrations" message could be more helpful

8 views
Skip to first unread message

Django

unread,
Dec 6, 2020, 8:04:54 AM12/6/20
to django-...@googlegroups.com
#32247: "App does not have migrations" message could be more helpful
-------------------------------------+-------------------------------------
Reporter: berzi | Owner: (none)
Type: | Status: new
Uncategorized |
Component: Error | Version: 3.1
reporting | Keywords: documentation,
Severity: Normal | errors, error messages
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 1 |
-------------------------------------+-------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32247>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 7, 2020, 1:06:31 AM12/7/20
to django-...@googlegroups.com
#32247: "App does not have migrations" message could be more helpful
-------------------------------------+-------------------------------------
Reporter: berzi | Owner: (none)
Type: | Status: closed
Cleanup/optimization |
Component: Error reporting | Version: 3.1
Severity: Normal | Resolution: invalid
Keywords: documentation, | Triage Stage:
errors, error messages | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* type: Uncategorized => Cleanup/optimization
* ui_ux: 1 => 0
* resolution: => invalid


Comment:

Replying to [ticket:32247 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32247#comment:1>

Reply all
Reply to author
Forward
0 new messages