diff --git a/onadata/libs/renderers/renderers.py b/onadata/libs/renderers/renderers.py index 45994cbff9..f1d2082981 100644 --- a/onadata/libs/renderers/renderers.py +++ b/onadata/libs/renderers/renderers.py @@ -7,13 +7,11 @@ import math from io import BytesIO -from future.utils import iteritems - +import pytz from django.utils.dateparse import parse_datetime from django.utils.encoding import smart_text from django.utils.xmlutils import SimplerXMLGenerator - -import pytz +from future.utils import iteritems from rest_framework import negotiation from rest_framework.compat import six from rest_framework.renderers import (BaseRenderer, JSONRenderer, @@ -31,6 +29,14 @@ 'meta/sessionID', ] +FORMLIST_MANDATORY_FIELDS = [ + 'formID', + 'name', + 'version', + 'hash', + 'downloadUrl' +] + def pairing(val1, val2): """ @@ -244,9 +250,12 @@ def _to_xml(self, xml, data): elif isinstance(data, dict): for (key, value) in iteritems(data): - xml.startElement(key, {}) - self._to_xml(xml, value) - xml.endElement(key) + if key not in FORMLIST_MANDATORY_FIELDS and value is None: + pass + else: + xml.startElement(key, {}) + self._to_xml(xml, value) + xml.endElement(key) elif data is None: # Don't output any value