title: How to programatically set a foreign key of a ModelResource POST data
body: <p>in a django-tastypie app I have the following Django-models:</p>
  
  <pre><code>class Car(models.Model):
      name=models.CharField('name',max_length=64)
  
  class CarTrack(models.Model):
      car=models.ForeignKey(Car)
      tdata=models.CharField('track data',max_length=255)
      created = models.DateTimeField('created time',auto_now_add=True)
  </code></pre>
  
  <p>I created the following tastypie resources:</p>
  
  <pre><code>class CarRsc(ModelResource):
      class Meta:
          queryset=Car.objects.all()
          resource_name='car'
          authentication = Authentication()
          authorization=Authorization()
  
  class CarTrackRsc(ModelResource):
      car=fields.ForeignKey(CarRsc, 'car')
      class Meta:
          queryset=Detection.objects.all()
          resource_name='track'
          authentication = Authentication()
          authorization=Authorization()
      def hydrate(self, bundle):
          if not bundle.obj.pk:
              bundle.obj.car=bundle.request.user.get_profile().car
          return bundle
  </code></pre>
  
  <p>When the client post a new CarTrackRsc(e.g., {"tdata":"blablabla"}), I want set the foreign key  of the CarTrack to a certain car. In the above example I try to override the hydrate method to achieve it(by fetching out the car of the current login user). But seemed it doesn't work. Is that the correct way to do so ? The tastypie document do give an example on how to <a href="http://django-tastypie.readthedocs.org/en/latest/resources.html#hydrate" rel="nofollow">use the hydrate method</a>, but it's just about simple field, no further hint on relation field(e.g., foreign key) is given there.</p>