# Buggy code
def as_form_field(self):
    values = {}
    for key, value in self.value.items():
        if isinstance(value, (list, dict)):
            values[key] = value
        else:
            values[key] = "" if value is None else force_text(value)
    return self.__class__(self._field, values, self.errors, self._prefix)


# Traceback (AttributeError)
Traceback (most recent call last):
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/core/handlers/base.py", line 164, in get_response
response = response.render()
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/response.py", line 158, in render
self.content = self.rendered_content
File "<path_to_virtualenv>/lib/python2.7/site-packages/rest_framework/response.py", line 60, in rendered_content
ret = renderer.render(self.data, media_type, context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/rest_framework/renderers.py", line 669, in render
context = self.get_context(data, accepted_media_type, renderer_context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/rest_framework/renderers.py", line 646, in get_context
'post_form': self.get_rendered_html_form(data, view, 'POST', request),
File "<path_to_virtualenv>/lib/python2.7/site-packages/rest_framework/renderers.py", line 513, in get_rendered_html_form
[('template', 'rest_framework/api_form.html')]
File "<path_to_virtualenv>/lib/python2.7/site-packages/rest_framework/renderers.py", line 367, in render
return template.render(context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/backends/django.py", line 74, in render
return self.template.render(context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/base.py", line 209, in render
return self._render(context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/base.py", line 201, in _render
return self.nodelist.render(context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/defaulttags.py", line 217, in render
nodelist.append(node.render(context))
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/defaulttags.py", line 329, in render
return nodelist.render(context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "<path_to_virtualenv>/lib/python2.7/site-packages/django/template/base.py", line 1195, in render
return func(*resolved_args, **resolved_kwargs)
File "<path_to_virtualenv>/lib/python2.7/site-packages/rest_framework/templatetags/rest_framework.py", line 31, in render_field
return renderer.render_field(field, style)
File "<path_to_virtualenv>/lib/python2.7/site-packages/rest_framework/renderers.py", line 325, in render_field
field = field.as_form_field()
File "<path_to_virtualenv>/lib/python2.7/site-packages/rest_framework/utils/serializer_helpers.py", line 99, in as_form_field
for key, value in self.value.items():
AttributeError: 'NoneType' object has no attribute 'items'

# Fixed code
def as_form_field(self):
    if self.value is None:
        return ""

    values = {}
    for key, value in self.value.items():
        if isinstance(value, (list, dict)):
            values[key] = value
        else:
            values[key] = "" if value is None else force_text(value)
    return self.__class__(self._field, values, self.errors, self._prefix)