﻿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
12546	Definining __len__ on a model object breaks it's serialization	casbon	Natalia Bidart	"In line 37 of django.core.serializers.python you have: 
{{{
    def handle_field(self, obj, field):
        value = field._get_val_from_obj(obj)
}}}

This calls django.db.models.fields.__init__ line 274:

{{{
    def _get_val_from_obj(self, obj):
        if obj:
            return getattr(obj, self.attname)
        else:
            return self.get_default()
}}}

Now suppose obj has a __len__ which is returning zero.  This means 'if obj' is False, then this method returns the default value rather than the object's value. 

Suugested fix is to change 'if obj' to 'if obj is not None'."		closed	Core (Other)	1.1		fixed			Accepted	0	0	0	0	0	0
