maxpoletaev / django-micro

Django as a microframework
BSD 2-Clause "Simplified" License
277 stars 22 forks source link

No module named "example", when I try to run application from example #15

Closed krosenmann closed 6 years ago

krosenmann commented 6 years ago

(.venv) ~/sources/wisdomchest/django-micro/example$ python app.py migrate
Traceback (most recent call last):
File "app.py", line 19, in configure(locals(), django_admin=True) File "/home/roman/sources/wisdomchest/.venv/lib/python3.6/site-packages/django_micro.py", line 83, in configure _create_app(inspect.stack()) # load application from parent module File "/home/roman/sources/wisdomchest/.venv/lib/python3.6/site-packages/django_micro.py", line 34, in _create_app import_module(app_module) File "/home/roman/sources/wisdomchest/.venv/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'example'

If I try to import this module from +1 level of file system then importing work correctly either running with uwsgi. Uwsgi backtrace from example folder shows the same error.

I found that U cannot import module when U stay in imported module folder. It looks like a reason.

Django 2.0.8, python 3.6

krosenmann commented 6 years ago

And with sys.path.append('..') everything works fine, but adding this string to every project looks kinda stupid.

maxpoletaev commented 6 years ago

Seems I accidentally removed a line that uses the parent directory as the import root in one of the latest commits. I’ll fix this asap! Thank you for reporting!

maxpoletaev commented 6 years ago

Fixed in 1.7.2