Cannot import name 'FieldDoesNotExist'

I am trying to run command: python3 manage.py runserver 0:80 and I get the below error

Exception in thread django-main-thread:
Traceback (most recent call last):File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib64/python3.6/threading.py", line 864, in run                                                                                                                                                                                     self._target(*self._args, **self._kwargs)                                                                                                                                                                                                  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 64, in wrapper                                                                                                                                                  fn(*args, **kwargs)                                                                                                                                                                                                                        File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run                                                                                                                             self.check(display_num_errors=True)                                                                                                                                                                                                        File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 423, in check                                                                                                                                               databases=databases,                                                                                                                                                                                                                       File "/usr/local/lib/python3.6/site-packages/django/core/checks/registry.py", line 76, in run_checks                                                                                                                                           new_errors = check(app_configs=app_configs, databases=databases)                                                                                                                                                                           File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 13, in check_url_config                                                                                                                                         return check_resolver(resolver)                                                                                                                                                                                                            File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver                                                                                                                                           return check_method()                                                                                                                                                                                                                      File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 416, in check                                                                                                                                                     for pattern in self.url_patterns:                                                                                                                                                                                                          File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__                                                                                                                                                  res = instance.__dict__[self.name] = self.func(instance)                                                                                                                                                                                   File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 602, in url_patterns                                                                                                                                              patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)                                                                                                                                                                File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__                                                                                                                                                  res = instance.__dict__[self.name] = self.func(instance)                                                                                                                                                                                   File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 595, in urlconf_module                                                                                                                                            return import_module(self.urlconf_name)                                                                                                                                                                                                    File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module                                                                                                                                                                  return _bootstrap._gcd_import(name[level:], package, level)                                                                                                                                                                                File "<frozen importlib._bootstrap>", line 994, in _gcd_import                                                                                                                                                                               File "<frozen importlib._bootstrap>", line 971, in _find_and_load                                                                                                                                                                            File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked                                                                                                                                                                   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked                                                                                                                                                                            File "<frozen importlib._bootstrap_external>", line 678, in exec_module                                                                                                                                                                      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed                                                                                                                                                                 File "/home/rc/qrd/qos-dashboard/config/urls.py", line 4, in <module>                                                                                                                                                                          from rest_framework_swagger.views import get_swagger_view                                                                                                                                                                                  File "/usr/local/lib/python3.6/site-packages/rest_framework_swagger/views.py", line 3, in <module>                                                                                                                                             from rest_framework.renderers import CoreJSONRenderer                                                                                                                                                                                      File "/usr/local/lib/python3.6/site-packages/rest_framework/renderers.py", line 24, in <module>                                                                                                                                                from rest_framework import VERSION, exceptions, serializers, status                                                                                                                                                                        File "/usr/local/lib/python3.6/site-packages/rest_framework/serializers.py", line 25, in <module>                                                                                                                                              from django.db.models.fields import FieldDoesNotExist                                                                                                                                                                                    ImportError: cannot import name 'FieldDoesNotExist'                                                                                                                                                                                                                                                                                                                                                                                                                                       Traceback (most recent call last):                                                                                                                                                                                                             File "/usr/local/lib/python3.6/site-packages/django/template/utils.py", line 66, in __getitem__                                                                                                                                                return self._engines[alias]                                                                                                                                                                                                              KeyError: 'django'                                                                                                                                                                                                                                                                                                                                                                                                                                                                        During handling of the above exception, another exception occurred:                                                                                                                                                                                                                                                                                                                                                                                                                       Traceback (most recent call last):                                                                                                                                                                                                             File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 121, in get_package_libraries                                                                                                                           module = import_module(entry[1])                                                                                                                                                                                                           File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module                                                                                                                                                                  return _bootstrap._gcd_import(name[level:], package, level)                                                                                                                                                                                File "<frozen importlib._bootstrap>", line 994, in _gcd_import                                                                                                                                                                               File "<frozen importlib._bootstrap>", line 971, in _find_and_load                                                                                                                                                                            File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked                                                                                                                                                                   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked                                                                                                                                                                            File "<frozen importlib._bootstrap_external>", line 678, in exec_module                                                                                                                                                                      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed                                                                                                                                                                 File "/usr/local/lib/python3.6/site-packages/rest_framework/templatetags/rest_framework.py", line 15, in <module>                                                                                                                              from rest_framework.renderers import HTMLFormRenderer                                                                                                                                                                                      File "/usr/local/lib/python3.6/site-packages/rest_framework/renderers.py", line 24, in <module>                                                                                                                                                from rest_framework import VERSION, exceptions, serializers, status                                                                                                                                                                        File "/usr/local/lib/python3.6/site-packages/rest_framework/serializers.py", line 25, in <module>                                                                                                                                              from django.db.models.fields import FieldDoesNotExist                                                                                                                                                                                    ImportError: cannot import name 'FieldDoesNotExist'                                                                                                                                                                                                                                                                                                                                                                                                                                       The above exception was the direct cause of the following exception:                                                                                                                                                                                                                                                                                                                                                                                                                      Traceback (most recent call last):                                                                                                                                                                                                             File "manage.py", line 22, in <module>                                                                                                                                                                                                         execute_from_command_line(sys.argv)                                                                                                                                                                                                        File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line                                                                                                                       utility.execute()                                                                                                                                                                                                                          File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 413, in execute                                                                                                                                         self.fetch_command(subcommand).run_from_argv(self.argv)                                                                                                                                                                                    File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv                                                                                                                                       self.execute(*args, **cmd_options)                                                                                                                                                                                                         File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 61, in execute                                                                                                                                super().execute(*args, **options)                                                                                                                                                                                                          File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 398, in execute                                                                                                                                             output = self.handle(*args, **options)                                                                                                                                                                                                     File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 96, in handle                                                                                                                                 self.run(**options)                                                                                                                                                                                                                        File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 103, in run                                                                                                                                   autoreload.run_with_reloader(self.inner_run, **options)                                                                                                                                                                                    File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 638, in run_with_reloader                                                                                                                                       start_django(reloader, main_func, *args, **kwargs)                                                                                                                                                                                         File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 623, in start_django                                                                                                                                            reloader.run(django_main_thread)                                                                                                                                                                                                           File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 328, in run                                                                                                                                                     autoreload_started.send(sender=self)                                                                                                                                                                                                       File "/usr/local/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 182, in send                                                                                                                                                 for receiver in self._live_receivers(sender)                                                                                                                                                                                               File "/usr/local/lib/python3.6/site-packages/django/dispatch/dispatcher.py", line 182, in <listcomp>                                                                                                                                           for receiver in self._live_receivers(sender)                                                                                                                                                                                               File "/usr/local/lib/python3.6/site-packages/django/template/autoreload.py", line 44, in watch_for_template_changes                                                                                                                            for directory in get_template_directories():                                                                                                                                                                                               File "/usr/local/lib/python3.6/site-packages/django/template/autoreload.py", line 17, in get_template_directories                                                                                                                              for backend in engines.all():                                                                                                                                                                                                              File "/usr/local/lib/python3.6/site-packages/django/template/utils.py", line 90, in all                                                                                                                                                        return [self[alias] for alias in self]                                                                                                                                                                                                     File "/usr/local/lib/python3.6/site-packages/django/template/utils.py", line 90, in <listcomp>                                                                                                                                                 return [self[alias] for alias in self]                                                                                                                                                                                                     File "/usr/local/lib/python3.6/site-packages/django/template/utils.py", line 81, in __getitem__                                                                                                                                                engine = engine_cls(params)                                                                                                                                                                                                                File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 25, in __init__                                                                                                                                         options['libraries'] = self.get_templatetag_libraries(libraries)                                                                                                                                                                           File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 43, in get_templatetag_libraries                                                                                                                        libraries = get_installed_libraries()                                                                                                                                                                                                      File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 108, in get_installed_libraries                                                                                                                         for name in get_package_libraries(pkg):                                                                                                                                                                                                    File "/usr/local/lib/python3.6/site-packages/django/template/backends/django.py", line 126, in get_package_libraries                                                                                                                           ) from e                                                                                                                                                                                                                                 django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'rest_framework.templatetags.rest_framework': cannot import name 'FieldDoesNotExist'

I am trying to run the django code in local or migrate it even. It should have been with no error/warnings, but suddenly today I am getting all these warnings. Earlier it was related to library 'six' which resolved thru: pip install django-utils-six . I even installed mysqlclient 2.0.1 before that.

Try python3 manage.py runserver without the specifications and make sure you are in the same directory as the manage.py file in your command line.

Back to Top