kevin-brown/drf-json-api — pull request #19 by holandes22 (2014-11-01 07:25:03+00:00)
Title: A more generic way to create URL based template

As mentioned in issue #17, the method used assumes that the lookup field is 'pk', but this in fact can be anything. This fixes that issue.
Another issue with the 'reverse' approach was that it wouldn't match ids which must include dashes or underscores, this takes care of that as well.

One problem I can see, if that the URL template from reverse_dict has more than one value.
The template looks like this:

resolver.reverse_dict["team-detail"]
([(u'api/v1/teams/%(id)s/', [u'id'])], 'api/v1/teams/(?P\\d+)/$', {})

but django allows the urls to contain more than one dynamic segments:

([(u'api/v1/teams/%(id)s/blah/%(blahid)s', [u'id', u'blahid'])], ...)

But this wasn't considered either by the previous approach