makemigration causing error "TypeError: expected str, bytes or os.PathLike object, not NoneType"

makemigration causing error "TypeError: expected str, bytes or os.PathLike object, not NoneType"

运行 docker 容器中的 makemigration 命令导致了这个错误,谁能帮我找出问题所在?

python3.7 manage.py makemigrations
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/reportlab/lib/utils.py", line 667, in open_for_read
    return open_for_read_by_name(name,mode)
  File "/usr/local/lib/python3.7/site-packages/reportlab/lib/utils.py", line 611, in open_for_read_by_name
    return open(name,mode)
TypeError: expected str, bytes or os.PathLike object, not NoneType

您使用的是旧版本 django

from importlib import import_module
import_module('yourapp.migrations')

import_module 行为在 python 3.6(或 3.7,我不记得了)中发生了变化。

提高你的 django 版本或者使用 python < 3.7

请检查是否缺少 your_app/migrations/__init__.py

如果它不存在,django 可能会抛出这个异常,在这种情况下会抛出 solition

-> 添加 __init__.py 再执行 python manage.py makemigrations