Linked Questions

Popular Questions

DJANGO 1.11 - Can't find fixtures

Asked by At

Problem

I was trying to use fixtures to populate my database, so I started by reading through the documentation for loaddata and by default, it looks in the fixtures directory inside each app for fixtures. My problem is that when I run python manage.py loaddata I'm getting an error, but when I give it the path for teams.yaml it works fine. Do I need to setup something for it to work?

Documentation

https://docs.djangoproject.com/en/1.11/howto/initial-data/#where-django-finds-fixture-files

Error

usage: manage.py loaddata [-h] [--version] [-v {0,1,2,3}]
                          [--settings SETTINGS] [--pythonpath PYTHONPATH]
                          [--traceback] [--no-color] [--database DATABASE]
                          [--app APP_LABEL] [--ignorenonexistent] [-e EXCLUDE]
                          fixture [fixture ...]
manage.py loaddata: error: No database fixture specified. Please provide the path of at least one fixture in the command line.

Team App Dir

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

Model

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'), 
        )

Fixture (teams.yaml)

- model: team.Team
  pk: 1
  fields:
    team_name: team_name_example
    team_descrition: team_description_example

Related Questions