title: django-tastypie: linking a ModelResource to a Resource
body: <p>I'm currently trying django-tastypie to design a RESTful api. I'm facing a problem:</p>
  
  <pre><code># the RevisionObject retrieve commits info through pysvn
  # This Resource is fully functionnal (RevisionObject code is not here)
  class RevisionResource(Resource):
      id = fields.CharField(attribute='revision')
      description = fields.CharField(attribute='message')
      author = fields.CharField(attribute='author')
      changed_path = fields.ListField(attribute='changed_paths')
  
      class Meta:
          object_class = RevisionObject
          allowed_methods = ['get']
          resource_name = 'revision'
  
  class RevisionToApplyResource(ModelResource):
      #### here's the problem
      revision = fields.ToManyField(RevisionResource, 'revision')
      ####
      class Meta:
          queryset = RevisionToApply.objects.all()
  </code></pre>
  
  <p>In my models.py I have:</p>
  
  <pre><code>class RevisionToApply(models.Model):
      patch = models.ForeignKey(PatchRequest)
      revision = models.PositiveIntegerField()
      applied = models.BooleanField(default = False)
  </code></pre>
  
  <p>My problem is that the RevisionToApply models (for django) uses an int to the revision.</p>
  
  <p>How can I tell tastypie to use the revision field of RevisionToApplyResource as a pointer to a RevisionResource? If the ToXxxxField are only for linking with django models, what is the perfect moment to insert the ResourceObject?</p>
  
  <p>thanks.</p>
  
  <pre><code>class NoForeignKeyToOneField(ToOneField):
      def dehydrate(self, bundle):
          try:
              obj_key = getattr(bundle.obj, self.attribute)
              foreign_obj = self.to_class().obj_get(pk=obj_key)
          except ObjectDoesNotExist:
              foreign_obj= None
  
          if not foreign_obj:
              if not self.null:
                  raise ApiFieldError("The model '%r' has an empty attribute"
                     "'%s' and doesn't allow null value." % (bundle.obj,
                     self.attribute))
              return None
  
          self.fk_resource = self.get_related_resource(foreign_obj)
          fk_bundle = Bundle(obj=foreign_obj, request=bundle.request)
          return self.dehydrate_related(fk_bundle, self.fk_resource)
  </code></pre>