YAML Fixture is not working. DeserializationError

370 views
Skip to first unread message

abisson

unread,
Apr 10, 2012, 12:47:29 AM4/10/12
to django...@googlegroups.com
Good afternoon,

I am trying to do: python manage.py syncdb and I always get this error:

Problem installing fixture '.../translations/fixtures/initial_data.yaml': Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 190, in handle
    for obj in objects:
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/serializers/pyyaml.py", line 62, in Deserializer
    raise DeserializationError(e)
DeserializationError: mapping values are not allowed here
  in "/.../translations/fixtures/initial_data.yaml", line 2, column 7

Model:

from django.db import models

class Language(models.Model):
    code = models.CharField(max_length=2)
    display_name = models.CharField(max_length=16, blank=False)

def __unicode__(self):
    return self.display_name


Fixture:

- model: translations.Language
    pk: 1
    fields:
        code: fr
        display_name: Français
- model: translations.Language
    pk: 2
    fields:
        code: en
        display_name: English


I am running PyYAML 3.10! Any ideas?! :(

Thanks a lot,

Antoine


James Rivett-Carnac

unread,
Apr 23, 2012, 8:06:38 AM4/23/12
to django...@googlegroups.com
Your yaml doesn't seem to be correctly formated, should be:


- model: translations.Language
  pk: 1
  fields:
      code: fr
      display_name: Français
- model: translations.Language
  pk: 2
  fields:
      code: en
      display_name: English

model, pk, and fields are all on the same indentation level.  Just spent some time trying to debug the same problem.

rgds

james
Reply all
Reply to author
Forward
0 new messages