  import re
  
  
  
  def _model_to_dict(instance, fields=None, exclude=None):
      """
      This is a clone of Django's ``django.forms.model_to_dict`` except that it
      doesn't coerce related objects into primary keys.
      """
      opts = instance._meta
 
</s> remove     This is a clone of Django's ``django.forms.model_to_dict`` except that it
    doesn't coerce related objects into primary keys.
 </s> add     Given a model instance, return a ``dict`` representing the model.
    
    The implementation is similar to Django's ``django.forms.model_to_dict``, except:

    * It doesn't coerce related objects into primary keys.
    * It doesn't drop ``editable=False`` fields.
    * It also supports attribute or method fields on the instance or resource. </s> remove def _form_to_data(form):
 </s> add class BaseResource(object): </s> remove     Returns a dict containing the data in a form instance.
    
    This code is pretty much a clone of the ``Form.as_p()`` ``Form.as_ul``
    and ``Form.as_table()`` methods, except that it returns data suitable
    for arbitrary serialization, rather than rendering the result directly
    into html.
 </s> add     Base class for all Resource classes, which simply defines the interface they provide. </s> remove     ret = {}
    for name, field in form.fields.items():
        if not form.is_bound:
            data = form.initial.get(name, field.initial)
            if callable(data):
                data = data()
        else:
            if isinstance(field, FileField) and form.data is None:
                data = form.initial.get(name, field.initial)
            else:
                data = field.widget.value_from_datadict(form.data, form.files, name)
        ret[name] = field.prepare_value(data)
    return ret


class BaseResource(object):
    """Base class for all Resource classes, which simply defines the interface they provide."""
 </s> add     fields = None
    include = None
    exclude = None </s> remove             response.cleaned_content = self.object_to_data(response.raw_content)
 </s> add             response.cleaned_content = self.filter_response(response.raw_content)
def _model_to_dict(instance, resource=None):
  import re
  
  
  
def _model_to_dict(instance, resource=None):
      """
      This is a clone of Django's ``django.forms.model_to_dict`` except that it
      doesn't coerce related objects into primary keys.
      """
      opts = instance._meta
keep keep keep keep replace keep keep keep keep keep
 Sorting out resources.  Doing some crazy magic automatic url resolving stuff.  Yum. 
djangorestframework/resources.py