              format = self.format
  
          try:
              return reverse(view_name, kwargs=kwargs, request=request, format=format)
          except NoReverseMatch:
              pass
  
 
</s> remove         slug = getattr(obj, self.slug_field, None)

        if not slug:
            raise Exception('Could not resolve URL for field using view name "%s"' % view_name)

        kwargs = {self.slug_url_kwarg: slug}
        try:
            return reverse(view_name, kwargs=kwargs, request=request, format=format)
        except NoReverseMatch:
            pass
 </s> add         if self.pk_url_kwarg != 'pk':
            # Only try pk lookup if it has been explicitly set.
            # Otherwise, the default `lookup_field = 'pk'` has us covered.
            kwargs = {self.pk_url_kwarg: obj.pk}
            try:
                return reverse(view_name, kwargs=kwargs, request=request, format=format)
            except NoReverseMatch:
                pass </s> remove         kwargs = {self.pk_url_kwarg: obj.pk, self.slug_url_kwarg: slug}
        try:
            return reverse(view_name, kwargs=kwargs, request=request, format=format)
        except NoReverseMatch:
            pass
 </s> add         slug = getattr(obj, self.slug_field, None)
        if slug:
            # Only use slug lookup if a slug field exists on the model
            kwargs = {self.slug_url_kwarg: slug}
            try:
                return reverse(view_name, kwargs=kwargs, request=request, format=format)
            except NoReverseMatch:
                pass </s> remove         lookup_field = getattr(obj, self.lookup_field)
        kwargs = {self.lookup_field: lookup_field}
 </s> add 
        lookup_field = getattr(obj, self.lookup_field)
        kwargs = {self.lookup_field: lookup_field}
              format = self.format
  
        lookup_field = getattr(obj, self.lookup_field)
        kwargs = {self.lookup_field: lookup_field}
          try:
              return reverse(view_name, kwargs=kwargs, request=request, format=format)
          except NoReverseMatch:
              pass
  
keep add keep keep keep keep keep
 Backwards compatible approach to HyperlinkedIdentityField URLs.  Closes #892 
rest_framework/relations.py