Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法使用Django和Docker在sqlite3中为初始数据设定种子 更新:_Python_Python 3.x_Docker_Docker Compose_Dockerfile - Fatal编程技术网

Python 无法使用Django和Docker在sqlite3中为初始数据设定种子 更新:

Python 无法使用Django和Docker在sqlite3中为初始数据设定种子 更新:,python,python-3.x,docker,docker-compose,dockerfile,Python,Python 3.x,Docker,Docker Compose,Dockerfile,我也在研究,但会继续添加我认为可能有用的链接 这是我遇到的错误,因为我无法使用docker命令写入数据库(您将在下面看到)。这是我的假设 这是我的文件夹结构 docker compose.yml version: "3" services: django: build: ./api command: ["python3", "manage.py", "runserver", &q

我也在研究,但会继续添加我认为可能有用的链接


这是我遇到的错误,因为我无法使用docker命令写入数据库(您将在下面看到)。这是我的假设



这是我的文件夹结构


docker compose.yml

version: "3"

services:
  django:
    build: ./api
    command: ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
    volumes:
      - ./api:/app
    ports:
      - "8000:8000"
  frontend:
    build: ./frontend
    volumes:
      - ./frontend:/app
      - /app/node_modules
    ports:
      - "3000:3000"

volumes:
  node-modules:

Dockerfile(在api文件夹内)



我已经尝试了我能够搜索到的大多数可能的项目,如果有人能在这里提供帮助,我将不胜感激。

运行Docker Image CLI中的命令

# Run migrations and load seed data (using SQLite)
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py loaddata portal/fixtures/seed.yaml
python3 manage.py loaddata scheduler/fixtures/seed.yaml

按顺序执行。

卷:隐藏图像生成的所有内容(对于前端容器,还告诉Docker使用旧版本的
节点模块
树)。如果删除所有
卷:
块,效果会更好吗?是的,我也删除了较旧的卷,但不起作用。它没有在数据库中初始化和添加值。必须按照答案中的建议手动执行,并且成功了。
# Run migrations and load seed data (using SQLite)
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py loaddata portal/fixtures/seed.yaml
python3 manage.py loaddata scheduler/fixtures/seed.yaml