  
  
  class RelationsList(list):
      _deleted = []
  
  class NestedValidationError(ValidationError):
      """
      The default ValidationError behavior is to stringify each item in the list
 
</s> remove         # The HTMLFormRenderer currently uses something of a hack to render
        # the content, by translating each of the serializer fields into
        # an html form field, creating a dynamic form using those fields,
        # and then rendering that form.

        # This isn't strictly neccessary, as we could render the serilizer
        # fields to HTML directly.  The implementation is historical and will
        # likely change at some point.

        self.renderer_context = renderer_context or {}
        request = self.renderer_context['request']

        # Creating an on the fly form see:
        # http://stackoverflow.com/questions/3915024/dynamically-creating-classes-python
        fields = self.data_to_form_fields(data)
        DynamicForm = type(str('DynamicForm'), (forms.Form,), fields)
        data = None if data.empty else data
 </s> add         renderer_context = renderer_context or {}
        request = renderer_context['request'] </s> remove         context = RequestContext(request, {'form': DynamicForm(data)})

 </s> add         context = RequestContext(request, {'form': data}) </s> remove     def data_to_form_fields(self, data):
        fields = {}
        for key, val in data.fields.items():
            if getattr(val, 'read_only', True):
                # Don't include read-only fields.
                continue

            if getattr(val, 'fields', None):
                # Nested data not supported by HTML forms.
                continue

            kwargs = {}
            kwargs['required'] = val.required

            #if getattr(v, 'queryset', None):
            #    kwargs['queryset'] = v.queryset

            if getattr(val, 'choices', None) is not None:
                kwargs['choices'] = val.choices

            if getattr(val, 'regex', None) is not None:
                kwargs['regex'] = val.regex

            if getattr(val, 'widget', None):
                widget = copy.deepcopy(val.widget)
                kwargs['widget'] = widget

            if getattr(val, 'default', None) is not None:
                kwargs['initial'] = val.default

            if getattr(val, 'label', None) is not None:
                kwargs['label'] = val.label

            if getattr(val, 'help_text', None) is not None:
                kwargs['help_text'] = val.help_text

            fields[key] = val.form_field_class(**kwargs)

        return fields

 </s> add  </s> remove             value = field.field_to_native(obj, field_name)
 </s> add             if self._errors:
                value = self.init_data.get(field_name)
            else:
                value = field.field_to_native(obj, field_name)

            field._errors = self._errors.get(key) if self._errors else None
            field._name = field_name
            field._value = value
            if not field.label:
                field.label = pretty_name(key)

def pretty_name(name):
    """Converts 'first_name' to 'First name'"""
    if not name:
        return ''
    return name.replace('_', ' ').capitalize()


  
  
def pretty_name(name):
    """Converts 'first_name' to 'First name'"""
    if not name:
        return ''
    return name.replace('_', ' ').capitalize()


  class RelationsList(list):
      _deleted = []
  
  class NestedValidationError(ValidationError):
      """
      The default ValidationError behavior is to stringify each item in the list
keep add keep keep keep keep keep keep
 Serializers can now be rendered directly to HTML 
rest_framework/serializers.py