Repository navigation
Closed
Labels
Milestone
Description
Checklist
- I have verified that that issue exists against the
masterbranch 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.)
In testing an application against Django 2.0a1, I ran into a confusing error:
File ".tox/py36-django20/lib/python3.6/site-packages/rest_framework/serializers.py", line 30, in <module>
from rest_framework.compat import JSONField as ModelJSONField
File ".tox/py36-django20/lib/python3.6/site-packages/rest_framework/compat.py", line 26, in <module>
from django.core.urlresolvers import ( # Will be removed in Django 2.0
ModuleNotFoundError: No module named 'django.core.urlresolvers'After investigating, it is related to a shim for older Django versions which now breaks as of Django 2.0a1:
try:
from django.urls import (
NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve
)
except ImportError:
from django.core.urlresolvers import ( # Will be removed in Django 2.0
NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve
)| NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve |
It turns out, RegexURLResolver no longer exists. I would imagine this is related to the new simplified URL patterns.
I'm unsure what the exact fix is at this moment, as I haven't dug into the new url implementation(s) yet, but I do recall that the old regex functionality is being maintained.
Activity
thomwiggers commentedon Oct 2, 2017
Pretty sure it's
URLPatternandURLResolvernow. I'm trying to figure this one out.thomwiggers commentedon Oct 2, 2017
Ok, so as far as I've been able to figure out, they're far from drop-in replacements. The entire way resolving paths used to work appears to have been refactored and you would need to do some work to work with this new api. You would need some compatibility shim, as some of the attributes have been renamed or layers of indirection have been added since Django 2.0.
mastizada commentedon Oct 3, 2017
Its now
django.urls.resolvers.RegexURLPatternse-bastiaan commentedon Oct 3, 2017
django.urls.resolvers.RegexURLPatterndoesn't exist anymore either, it was changed in django/django@df41b5a.diemuzi commentedon Oct 6, 2017
Also running Django 2.x alpha with the latest Rest Framework
When running python manage.py compress the following output is returned:
https://gist.github.com/diemuzi/e9049c96b703d87d061caa6d018be3fd
Just adding it here in case it helps with any debugging. Would be happy to do anything else to help too.
anx-ckreuzberger commentedon Oct 9, 2017
I just installed DRF 3.7, and it seems that there still is a compatibility issue with Django 2.0 (a1):
Could be fixed by PR #5485