Cannot import app modules implementing Flask CLI Cannot import app modules implementing Flask CLI flask flask

Cannot import app modules implementing Flask CLI


I found the solution.

I had to delete the root dir __init__.py file.

I found this answer from the famous Miguel Grinberg:

https://github.com/miguelgrinberg/flasky/issues/310#issuecomment-340641813

These files (__init__.py) make python believe the main directory of the package is one directory above, so that is the directory that is added to the Python path. Usually you want your top-level directory to not be a Python package, so that the current directory goes to the path.

__


It is a matter of python way of import modules, not about Flask command.

Since command.py file is at the same level of the models folder you can just write:

import models.user_models as users

After that you can acces the user_models module from users reference:

import models.user_models as usersusers.some_function_name()