Description
Checklist
- I have verified that that issue exists against the
master
branch of Django REST framework. - I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- This is not a usage question. (Those should be directed to the discussion group instead.)
- This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
- I have reduced the issue to the simplest possible case.
- I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
Steps to reproduce
In any Django 1.11 project with a python2.7 interpreter, latest DRF version:
# In a Django Shell
from rest_framework.compat import urlparse,
urlparse.urlparse('https://google.fr')
Expected behavior
A ParseResult
object should be returned, from what I see here :
https://github.com/encode/django-rest-framework/blob/master/rest_framework/renderers.py#L997
Actual behavior
Results in : AttributeError: 'function' object has no attribute 'urlparse'
Same example works under Python3
More details:
It looks like this issue has been introduce by this commit : 8908934#diff-ce493f71b3679e91b72126c168670399R25 . A possible fix could be to replace ligne 25 of compat.py
(actually from urlparse import urlparse # noqa
) by import urlparse # noqa
(or a weirder import urlparse as urlparse # noqa
)
I noticed that by trying to access the http://localhost:8000/ws/schema.json
URL on my localhost. See paste for more details : https://pastebin.com/raw/51QgEcqG
If this is indeed an issue, I am volunteer to try and write a few tests so that type of cases get detected by the tests matrix.