﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16127	Queryset which uses defer() method not serialize in Json	eguevara2012@…	nobody	"Hello!
I have this function using json and a queryset with defer() method, but the fields not target in queryset, i need only ""id"" and ""nome"":

models.py
{{{
class Pessoa(models.Model):
    nome = models.CharField(max_length=50)
    data_nascimento = models.DateField()
    data_inclusao = models.DateField()
    cpf = models.CharField(max_length=14)
    telefone = models.CharField(max_length=13)
    celular = models.CharField(max_length=13)
    
    class Meta:
        abstract = True

class Proprietario(Pessoa):  
    endereco = models.ForeignKey(Endereco)

    def __unicode__(self):
            return ""%s, %s"" % (self.nome, self.cpf)
}}}

views.py:
{{{
def load_proprietarios(request):
    data = serializers.serialize('json',Proprietario.objects.defer('cpf','telefone','celular','data_nascimento','data_inclusao',),ensure_ascii=False))
    return HttpResponse(data, mimetype=""application/javascript"")
}}}

This is the output:
{{{
[{""pk"": 1, ""model"": ""proprietario.proprietario_deferred_celular_cpf_telefone_data_inclusao_data_nascimento"", ""fields"": {}}]
}}}

Note that the ""id"" and the ""nome"" fields (class Proprietario / class abstract Pessoa) does not appear after defer() method.

Regards."	Bug	new	Core (Serialization)	1.3	Normal				Accepted	0	0	0	0	0	
