SetField doesn't serialize correctly (for dump/loaddata)
georgedorn opened this issue · comments
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 format doesn't have a set notation, it probably should just serialize to the same format as the ListField.
I fully agree. Patches welcome.
A json set is a dict of empty keys