Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'is_authenticated' when running 'manage.py migrate' command #1564

Closed
WRJFontenot opened this issue Oct 7, 2017 · 1 comment
Labels
status: duplicate This issue has already been raised

Comments

@WRJFontenot
Copy link

WRJFontenot commented Oct 7, 2017

Issue type

[ ] Feature request
[X ] Bug report
[ ] Documentation

Environment

  • Python version: 3.4.7 & 3.6.2
  • NetBox version: 2.1.5

Description

Following successful completion of all prerequisite steps, when I run the database migrations, I get the following error:

[root@localhost netbox]# python3 manage.py migrate
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/rest_framework/settings.py", line 180, in import_from_string
module = import_module(module_path)
File "/usr/lib64/python3.4/importlib/init.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 2254, in _gcd_import
File "", line 2237, in _find_and_load
File "", line 2226, in _find_and_load_unlocked
File "", line 1200, in _load_unlocked
File "", line 1129, in _exec
File "", line 1471, in exec_module
File "", line 321, in _call_with_frames_removed
File "/opt/netbox-2.1.5/netbox/utilities/api.py", line 7, in
from rest_framework.compat import is_authenticated
ImportError: cannot import name 'is_authenticated'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/lib/python3.4/site-packages/django/core/management/init.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/lib/python3.4/site-packages/django/core/management/init.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python3.4/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/lib/python3.4/site-packages/django/core/management/base.py", line 327, in execute
self.check()
File "/usr/lib/python3.4/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/usr/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
issues.extend(super(Command, self)._run_checks(**kwargs))
File "/usr/lib/python3.4/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/usr/lib/python3.4/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/lib/python3.4/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/usr/lib/python3.4/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/usr/lib/python3.4/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/usr/lib/python3.4/site-packages/django/utils/functional.py", line 35, in get
res = instance.dict[self.name] = self.func(instance)
File "/usr/lib/python3.4/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib/python3.4/site-packages/django/utils/functional.py", line 35, in get
res = instance.dict[self.name] = self.func(instance)
File "/usr/lib/python3.4/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib64/python3.4/importlib/init.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 2254, in _gcd_import
File "", line 2237, in _find_and_load
File "", line 2226, in _find_and_load_unlocked
File "", line 1200, in _load_unlocked
File "", line 1129, in _exec
File "", line 1471, in exec_module
File "", line 321, in _call_with_frames_removed
File "/opt/netbox-2.1.5/netbox/netbox/urls.py", line 3, in
from rest_framework_swagger.views import get_swagger_view
File "/usr/lib/python3.4/site-packages/rest_framework_swagger/views.py", line 5, in
from rest_framework.schemas import SchemaGenerator
File "/usr/lib/python3.4/site-packages/rest_framework/schemas/init.py", line 32, in
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
File "/usr/lib/python3.4/site-packages/rest_framework/settings.py", line 223, in getattr
val = perform_import(val, attr)
File "/usr/lib/python3.4/site-packages/rest_framework/settings.py", line 168, in perform_import
return [import_from_string(item, setting_name) for item in val]
File "/usr/lib/python3.4/site-packages/rest_framework/settings.py", line 168, in
return [import_from_string(item, setting_name) for item in val]
File "/usr/lib/python3.4/site-packages/rest_framework/settings.py", line 184, in import_from_string
raise ImportError(msg)
ImportError: Could not import 'utilities.api.TokenAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ImportError: cannot import name 'is_authenticated'.

I also got the same exact error when running Python 3.6.2.

@WRJFontenot WRJFontenot changed the title ImportError: cann ot import name 'is_authenticated' when running 'manage.py migrate' command ImportError: cannot import name 'is_authenticated' when running 'manage.py migrate' command Oct 7, 2017
@lae
Copy link
Contributor

lae commented Oct 7, 2017

This is fixed in develop (was reported in #1563) - downgrading the djangorestframework dependency to 3.6.4 should resolve it for you on 2.1.5.

@jeremystretch jeremystretch added the status: duplicate This issue has already been raised label Oct 8, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: duplicate This issue has already been raised
Projects
None yet
Development

No branches or pull requests

3 participants