Sudip Kafle
Sudip Kafle

Reputation: 4391

Invalid model identifier in Django Fixture

My django fixture contains the following data:

- model: CkProject.NotificationType
  pk: 1
  fields:
    name: comment
    message: commented on your project

When I run python manage.py syncdb, it shows an error while loading the fixtures:

raise base.DeserializationError("Invalid model identifier:
'%s'" % model_identifier)
django.core.serializers.base.DeserializationError: Problem installing fixture
'....../source/apps/CkProject/fixtures/initial_data.yaml': 
Invalid model identifier: 'CkProject.NotificationType'

I have even tried with a json file instead of YAML and same error is returned.

UPDATE: Here is my models.py which is located in apps/Notification/models.py

class NotificationType(models.Model):
    class Meta:
        db_table = 'CkProject_notificationtype'

    name = models.CharField(max_length=50)
    message = models.TextField()

    def __unicode__(self):
        return self.name

Upvotes: 2

Views: 7615

Answers (1)

rczajka
rczajka

Reputation: 1840

You have probably moved your model from apps/CKProject/models.py to apps/Notification/models.py, so its app_label has changed and the model is identified by Django as Notification.NotificationType now. You should update your fixture accordingly.

Alternatively, you can also add app_label = 'CKProject' (see: app_label) to NotificationType's Meta object to make Django identify it as CKProject.NotificationType again.

Upvotes: 6

Related Questions