Empty list fields happen if many=True is used on the field. This means that the field is automatically initialised as an empty list, so this can only ever be sa list or None.
The side-effect of this was that it appears in as_dict() when it shouldn't, because the field isn't populated. This fixes it.
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
for attr, field in self.fields.items():
if not field.hidden or include_hidden:
value = getattr(self, attr)
- if value is not None:
+ if value not in (None, []):
obj_dict[field.name] = value
return obj_dict