django-nonrel/django-nonrel — Issue #4: djangotoolbox.fields.SetField not compatible with dumpdata/loaddata
Author: georgedorn
Created: 2012-01-17 19:18:19+00:00
State: open

This doesn't appear to affect ListField, which does serialize into correct json format. Also, this is most likely a problem with djangotoolbox, not django-nonrel, but I'm not sure where to submit issues for that project.

from django.db import models
from djangotoolbox import fields

class Post(SlugModel):
title = models.CharField(max_length=256)
user = models.ForeignKey(User)
content = models.TextField()
tags = fields.SetField(models.CharField(max_length=128, blank=True), null=True, blank=True)

Calling dumpdata on a Post object results in json like this:

{"pk": "4efb8096aae5710ad4000000", "model": "blog.post", "fields": {"tags": "set([u'home', u'features'])", "content":"foo", "user": "4ded8376aae5713406000010", "title": "My Title", "slug": "my-title"}}

Since the json doesn't have a set notation, it probably should just serialize to the same format as the ListField.