django-nonrel/djangotoolbox — Issue #9: SetField doesn't serialize correctly (for dump/loaddata)
Author: georgedorn
Created: 2012-01-17 19:22:33+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(models.Model):
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.