  
  
  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
      data = {}
  
      #print [rel.name for rel in opts.get_all_related_objects()]
 
</s> remove def _model_to_dict(instance, fields=None, exclude=None):
 </s> add def _model_to_dict(instance, resource=None): </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 def _form_to_data(form):
 </s> add class BaseResource(object): </s> remove 
    #print fields - (opts.fields + opts.many_to_many) 
    #for related in [rel.get_accessor_name() for rel in opts.get_all_related_objects()]:
    #    if fields and not related in fields:
    #        continue
    #    if exclude and related in exclude:
    #        continue
    #    data[related] = getattr(instance, related)
 </s> add         
        if extra_fields and f.name in extra_fields:
            extra_fields.remove(f.name)
    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.
  
  
  def _model_to_dict(instance, fields=None, exclude=None):
      """
    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.
    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.
      """
      opts = instance._meta
      data = {}
  
      #print [rel.name for rel in opts.get_all_related_objects()]
keep keep keep keep replace replace keep keep keep keep keep
 Sorting out resources.  Doing some crazy magic automatic url resolving stuff.  Yum. 
djangorestframework/resources.py