mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
python: domain: models: as_dict() should also exclude empty list fields
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>
This commit is contained in:
parent
fc982e550f
commit
ed07dee864
@ -193,7 +193,7 @@ class Model(metaclass=ModelMeta):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user