Ich bin sicher, es gibt hier eine einfache Antwort, aber ich kann es nicht sehen. Ich versuche, Fixtures in meine Datenbank zu laden, aber egal, welche Modell-ID ich verwende, bekomme ich den DeserializationError: invalid model identifier:...
Fehler.Keine gültige Modellkennung für Django-Fixture-Daten?
Dateistruktur:
testproject/
testapp/
fixtures/
data.json
__init__.py
models.py
tests.py
views.py
sqlite3.db
__init__.py
manage.py
settings.py
urls.py
Da dies mein erstes gehen an Armaturen, ich bin mit dem Modell von http://www.djangoproject.com/documentation/models/fixtures/:
from django.db import models
from django.conf import settings
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
pub_date = models.DateTimeField()
def __unicode__(self):
return self.headline
class Meta:
ordering = ('-pub_date', 'headline')
data.json:
[
{
"pk": "3",
"model": "testapp.article",
"fields":
{
"headline": "Time to reform copyright",
"pub_date": "2006-06-16 13:00:00"
}
},
{
"pk": "2",
"model": "testapp.article",
"fields":
{
"headline": "Poker has no place on ESPN",
"pub_date": "2006-06-16 12:00:00"
}
},
{
"pk": "1",
"model": "testapp.article",
"fields":
{
"headline": "Python program becomes self aware",
"pub_date": "2006-06-16 11:00:00"
}
}
]
Ich habe versucht testapp.article
, testproject.article
, testproject.testapp.article
und sie alle th Zeile den gleichen Fehler. Ich benutze 1.2.4 mit Python 2.6 und benutze Loaddata anstatt Syncdb. Irgendwelche Ideen?
Ich denke, dass app.modelclass das richtige Format ist. Haben Sie versucht, dumpdata zu sehen, was generiert wird? – luc