      Include a login snippet if REST framework's login view is in the URLconf.
      """
      try:
          login_url = reverse('rest_framework:login')
      except:
          return ''
  
      snippet = "<a href='%s?next=%s'>Log in</a>" % (login_url, request.path)
      return snippet
  
 
</s> remove     except:
 </s> add     except NoReverseMatch: </s> remove         except:
 </s> add         except NoReverseMatch: </s> remove         except:
 </s> add         except Exception: </s> remove         except:
 </s> add         except NoReverseMatch: </s> remove         except:
 </s> add         except NoReverseMatch:
    except NoReverseMatch:
      Include a login snippet if REST framework's login view is in the URLconf.
      """
      try:
          login_url = reverse('rest_framework:login')
    except NoReverseMatch:
          return ''
  
      snippet = "<a href='%s?next=%s'>Log in</a>" % (login_url, request.path)
      return snippet
  
keep keep keep keep replace keep keep keep keep keep
 Purge naked excepts.

Most of these had obvious exceptions which would be thrown. Some I'm not
sure about but they should at least catch only Exception so as not to
ignore SystemExit and other inappropriate Error classes. 
rest_framework/templatetags/rest_framework.py