Search code examples
django-modelsloaddata

Django 1.6.5 - Unable to load initial data from fixtures


I tried to load initial-data as suggested in djangoproject. But I couldn't able to load object on my database. But when I tried to load data, it always says

> python manage.py loaddata ./fixtures/initial_data.json
Installed 0 object(s) from 0 fixture(s)

But I have data on the initial_data.json [/test-project/tableTest/tableTest/fixtures/initial_data.json]

[
    {
        "model":"tableTest.person",
        "pk":1,
        "fields": {
            "name":"Kevin"
        }
    },
    {
        "model":"tableTest.person",
        "pk":2,
        "fields": {
            "name":"Harry"
        }
    },
    {
        "model":"tableTest.person",
        "pk":3,
        "fields": {
            "name":"Piter"
        }
    }
]

#models.py
from django.db import models


class Person(models.Model):
    name = models.CharField(max_length=100, verbose_name="full name")

I also tried ./manage.py loaddata pwd/tableTest/fixtures/initial_data.json but could not succeed. Please help me to suggest what I have missed.


Solution

  • This issue arises because I write definition for model at project directory instead of app directory and Table I defined on model was not created on running syncdb. Later I create a app and move fixtures, models.py,views.py to app directory, rewrite urls.py. Then the data was loaded successfully.