Djangorestframework compatibility with django

I am having difficulty upgrading an application from django 1.10 to django 2.2 (for a variety of reasons, I cannot go to django 3.x directly).

The current application runs fine and in its requirements.txt we specify django==1.10 and djangorestframework==3.5.3.

Upgrading to django==2.2, leaving the DRF where it is, results in an error being thrown from what apears to be a compatibility file that is installed in the virtual environment’s site-packages directory:

File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/rest_framework/”, line 31, in
from django.core.urlresolvers import ( # Will be removed in Django 2.0

I have tried letting DRF installed it’s latest version but it has a different issue: It says that there is no module called report

ModuleNotFoundError: No module named ‘report’

So is there a DRF version that works correctly with django==2.2 ?

The requirements section of the docs imply that the current version is compatible with Django 2.2.

Without seeing the complete error message associated with this, it’s going to be tough to provide any firm guidance. There might be another third-party module involved here. You may want to scan your code for any import statement referencing a module with that name.

You also didn’t specify what version of Python you’re doing this with - that’s another component that will need to be brought forward as well.

It’s best to upgrade Django one version at a time: from 1.10 to 1.11, then 1.11 to 2.0, etc. This is in the docs: Upgrading Django to a newer version | Django documentation | Django . This way you can ensure you aren’t missing any deprecation notices that were added for only a few versions. It doesn’t take too long when you get into the swing of it.

If you’re seeing compat problems with a library like DRF, read through its changelog to figure out which versions are compatible with the django version you’re on. DRF in particular lists the version compat in its announcements: 3.9 Announcement - Django REST framework

I am using python3.6 in a virtual environment.

The complete error trace is:

(raxak) [raxak@centos8 raxak]$ python3 test
Traceback (most recent call last):
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/rest_framework/”, line 27, in
from django.urls import (
ImportError: cannot import name ‘RegexURLPattern’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 22, in
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/”, line 381, in execute_from_command_line
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/”, line 375, in execute
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/commands/”, line 23, in run_from_argv
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/”, line 323, in run_from_argv
self.execute(*args, **cmd_options)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/”, line 364, in execute
output = self.handle(*args, **options)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/commands/”, line 53, in handle
failures = test_runner.run_tests(test_labels)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/test/”, line 632, in run_tests
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/test/”, line 570, in run_checks
call_command(‘check’, verbosity=self.verbosity)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/”, line 148, in call_command
return command.execute(*args, **defaults)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/”, line 364, in execute
output = self.handle(*args, **options)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/commands/”, line 64, in handle
fail_level=getattr(checks, options[‘fail_level’]),
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/”, line 390, in check
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/management/”, line 377, in _run_checks
return checks.run_checks(**kwargs)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/checks/”, line 72, in run_checks
new_errors = check(app_configs=app_configs)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/checks/”, line 13, in check_url_config
return check_resolver(resolver)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/core/checks/”, line 23, in check_resolver
return check_method()
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/urls/”, line 398, in check
for pattern in self.url_patterns:
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/utils/”, line 80, in get
res = instance.dict[] = self.func(instance)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/urls/”, line 571, in url_patterns
patterns = getattr(self.urlconf_module, “urlpatterns”, self.urlconf_module)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/utils/”, line 80, in get
res = instance.dict[] = self.func(instance)
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/django/urls/”, line 564, in urlconf_module
return import_module(self.urlconf_name)
File “/usr/lib64/python3.6/importlib/”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 665, in _load_unlocked
File “”, line 678, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/u01/rp/raxak/raxakprotect/”, line 22, in
from users.views import RaxakManage, Terms
File “/u01/rp/raxak/users/”, line 20, in
from rest_framework import viewsets, renderers
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/rest_framework/”, line 26, in
from rest_framework import generics, mixins, views
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/rest_framework/”, line 10, in
from rest_framework import mixins, views
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/rest_framework/”, line 10, in
from rest_framework.response import Response
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/rest_framework/”, line 13, in
from rest_framework.serializers import Serializer
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/rest_framework/”, line 30, in
from rest_framework.compat import JSONField as ModelJSONField
File “/home/raxak/.virtualenvs/raxak/lib/python3.6/site-packages/rest_framework/”, line 31, in
from django.core.urlresolvers import ( # Will be removed in Django 2.0
ModuleNotFoundError: No module named ‘django.core.urlresolvers’

Sorry, I wasn’t clear. That appears to be the problem you mentioned when you were trying to upgrade Django while using the old DRF. I thought you reported a different problem when you upgraded DRF - that’s what I thought we were trying to address.