python - makemigration 导致错误 "TypeError: expected str, bytes or os.PathLike object, not NoneType"

标签 python django python-3.x database-migration django-migrations

在 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

最佳答案

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

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

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

关于python - makemigration 导致错误 "TypeError: expected str, bytes or os.PathLike object, not NoneType",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56070036/

相关文章:

python - Django-s3direct上传图片

python - 在 Python 中将序列拆分为单个步骤的最优雅方法

python - Elasticsearch 按字段分组以获取第一次出现的值

database - 是否可以在同一个 Django 项目中使用不同的 SQLite 数据库?

Python登录多个模块输出两次

python - 如何获取按特定对象的相交标签数量排序的查询集?

python-3.x - 教师力量训练 PyTorch

python - 为什么我不能接受客户?

python - Django 列表序列化器批量更新失败, 'QuerySet' 对象没有属性 'pk'

python - 计算 Pandas 每周的变化(使用 groupby)?