Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
DJANGO 1.11-罐头和x27;我找不到固定装置 问题_Django_Django Fixtures - Fatal编程技术网

DJANGO 1.11-罐头和x27;我找不到固定装置 问题

DJANGO 1.11-罐头和x27;我找不到固定装置 问题,django,django-fixtures,Django,Django Fixtures,我试图使用fixture来填充我的数据库,所以我开始阅读loaddata的文档,默认情况下,它会在每个应用程序的fixture目录中查找fixture。我的问题是,当我运行python manage.py loaddata时,我得到了一个错误,但是当我为teams.yaml提供路径时,它工作得很好。我需要为它设置一些功能吗 文档 错误 团队应用程序主管 模型 固定装置(团队。yaml) 错误显示: 未指定数据库设备。请在命令行中提供至少一个夹具的路径。 在您的情况下,需要在loaddata命

我试图使用fixture来填充我的数据库,所以我开始阅读loaddata的文档,默认情况下,它会在每个应用程序的fixture目录中查找fixture。我的问题是,当我运行
python manage.py loaddata
时,我得到了一个错误,但是当我为teams.yaml提供路径时,它工作得很好。我需要为它设置一些功能吗

文档

错误 团队应用程序主管 模型 固定装置(团队。yaml) 错误显示:
未指定数据库设备。请在命令行中提供至少一个夹具的路径。

在您的情况下,需要在
loaddata
命令中提供
fixturename

python manage.py加载数据团队

在文档中指定,默认情况下,Django将使用指定的
fixturename
查找应用程序中的fixtures目录。此外,该命令还接受
/path/to/fixtures/
,这将覆盖fixtures目录的搜索。

是否应在设置文件中定义
FIXTURE\u DIRS
,以便django找到存在的fixtures

设置.py

FIXTURE_DIRS = [
    os.path.join(BASE_DIR, 'fixtures')
]
# statements


哦,谢谢,我误解了文档。你知道如何让它搜索所有应用程序中的所有装置吗?你的意思是,加载所有应用程序中的所有装置吗?是的,我想加载所有应用程序中的所有装置。你试试这个吗?:这正是我要找的。对不起,浪费了你的时间,我还在谷歌上游手好闲。谢谢你的耐心,我也犯了同样的错误。@bgsuello评论的链接得到了我所需要的。非常感谢。
team
├── admin.py
├── apps.py
├── fixtures
│   └── teams.yaml
├── __init__.py
├── migrations
│   ├── 0001_initial.py
│   ├── 0002_auto_20190204_0438.py
│   ├── 0003_remove_team_team_name.py
│   ├── `enter code here`0004_team_team_name.py
│   ├── __init__.py
│   └── __pycache__
│       ├── 0001_initial.cpython-36.pyc
│       ├── 0002_auto_20190204_0438.cpython-36.pyc
│       ├── 0003_remove_team_team_name.cpython-36.pyc
│       ├── 0004_team_team_name.cpython-36.pyc
│       └── __init__.cpython-36.pyc
├── models.py
├── __pycache__
│   ├── admin.cpython-36.pyc
│   ├── apps.cpython-36.pyc
│   ├── __init__.cpython-36.pyc
│   └── models.cpython-36.pyc
├── tests.py
└── views.py
from django.db import models

class Team(models.Model):
    team_name = models.CharField(max_length=32)
    team_description = models.TextField(max_length=512, blank=False)

    class Meta:
        permissions = (
            ('create_team', 'Can create a team'), 
        )
- model: team.Team
  pk: 1
  fields:
    team_name: team_name_example
    team_descrition: team_description_example
FIXTURE_DIRS = [
    os.path.join(BASE_DIR, 'fixtures')
]
# statements