title: Django Tastypie ToManyField not properly resolving related URIs
body: <p>I've got a Django backend that is using Tastypie to generate its RESTful API. The endpoint of this API does not sit at the top-level of the domain; rather, it exists in a "subfolder" location through the use of WSGIScriptAlias. Most, of the time, this works fine. But I've discovered that when one of my resources has a ToManyField relationship, Tastypie throws an error. Here is some of my relevant code. The WSGIScriptAlias line:</p>
  
  <pre><code>WSGIScriptAlias /english/rubric /var/webapps/django/rubric/apache/django.wsgi
  </code></pre>
  
  <p>Snippet from the resource that has problems:</p>
  
  <pre><code>class TraitResource(ModelResource):
      criteria = fields.ToManyField('rubric.rubric.api.CriterionResource', "criteria", related_name='trait', full = True)
  
      class Meta:
           queryset = Trait.objects.all()
           authentication=SessionAuthentication()
           list_allowed_methods=['get']
      always_return_data=True
  
  class CriterionResource(ModelResource):
  
      class Meta:
          queryset = Criterion.objects.all()
          authentication=SessionAuthentication()
          list_allowed_methods=['get']
      always_return_data=True
  </code></pre>
  
  <p>My urls.py:</p>
  
  <pre><code>v1_api = Api(api_name='v1')
  v1_api.register(TraitResource())
  v1_api.register(CriterionResource())
  
  urlpatterns = patterns('',  
      (r'^login/$', 'django_cas.views.login'),
      (r'^logout/$', 'django_cas.views.logout'),
      (r'^api/', include(v1_api.urls))
  )
  </code></pre>
  
  <p>Snippet from the error message:</p>
  
  <pre><code>{
  error_message: "{'path': u'english/rubric/api/v1/rubric', 'tried': [[&lt;RegexURLPattern None ^login/$&gt;], [&lt;RegexURLPattern None ^logout/$&gt;], [&lt;RegexURLResolver [&lt;RegexURLPattern api_v1_top_level ^(?P&lt;api_name&gt;v1)/?$&gt;, &lt;RegexURLResolver [&lt;RegexURLPattern api_dispatch_list ...
  </code></pre>
  
  <p>(it goes on from there to list all of the URLs it has tried and failed to find a match for).</p>
  
  <p>So if I understand correctly, what is happening is that, because of my WSGIScriptAlias, the related objects are reporting their full path as the resource URI, but then when tastypie goes to get the related objects to return with the one I've called, they aren't matching anything in urls.py (because it only needs the url patterns relative to the WSGI app mount point). I've verified this is the case by temporarily modifying the WSGIScriptAlias so the API sits at the root -- and then it all works fine. So what do I need to do in order to keep it with the subfolder URL pattern? I've played around a bit with both overriding prepend_urls and get_resource_uri, but am not really getting how those functions are used in a resource class and so I'm not sure if that's the right strategy for me. Thanks in advance.</p>