导入时出错 "openwisp_utils.admin import ReadOnlyAdmin"
Error importing "openwisp_utils.admin import ReadOnlyAdmin"
我正在尝试实施 django-freeradius,但是当我在 [=30] 内的 urlspatters 中写入行 * 时,我收到错误 cannot import name 'ReadOnlyAdmin' =] 我的项目。我曾尝试在 https://github.com/openwisp/django-freeradius/blob/master/tests/urls.py 中使用相同的配置,但它不起作用。
# myproject/urls.py
from django.contrib import admin
from django.urls import path, include
from openwisp_utils.admin_theme.admin import admin, openwisp_admin
openwisp_admin()
admin.autodiscover()
urlpatterns = [
url(r'^', include('django_freeradius.urls', namespace='freeradius')), #* This line
path('admin/', admin.site.urls),
]
我已经安装:
Python 3.6.8
姜戈 2.2.4
django-过滤器 2.1.0
django-freeradius 0.1a0
openwisp-utils 0.2.2
这些是我在 settings.py
中的应用
# myproject/settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_freeradius',
'django_filters',
]
而且,这是我 运行 python manage.py 运行server ()[=15 时的完整错误=]
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/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 "/mnt/c/Users/myuser/Documents/python/hotspot/env/src/django-freeradius/django_freeradius/admin.py", line 6, in <module>
from .base.admin import (
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/src/django-freeradius/django_freeradius/base/admin.py", line 9, in <module>
from openwisp_utils.admin import ReadOnlyAdmin, TimeReadonlyAdminMixin
ImportError: cannot import name 'ReadOnlyAdmin'
如果有人能告诉我这个错误的原因,我将不胜感激。
尝试安装openwisp-utils开发版:
pip install --upgrade http://github.com/openwisp/openwisp-utils/tarball/master
我正在尝试实施 django-freeradius,但是当我在 [=30] 内的 urlspatters 中写入行 * 时,我收到错误 cannot import name 'ReadOnlyAdmin' =] 我的项目。我曾尝试在 https://github.com/openwisp/django-freeradius/blob/master/tests/urls.py 中使用相同的配置,但它不起作用。
# myproject/urls.py
from django.contrib import admin
from django.urls import path, include
from openwisp_utils.admin_theme.admin import admin, openwisp_admin
openwisp_admin()
admin.autodiscover()
urlpatterns = [
url(r'^', include('django_freeradius.urls', namespace='freeradius')), #* This line
path('admin/', admin.site.urls),
]
我已经安装: Python 3.6.8 姜戈 2.2.4 django-过滤器 2.1.0 django-freeradius 0.1a0 openwisp-utils 0.2.2
这些是我在 settings.py
中的应用# myproject/settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_freeradius',
'django_filters',
]
而且,这是我 运行 python manage.py 运行server ()[=15 时的完整错误=]
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/python3.6/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/lib/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 "/mnt/c/Users/myuser/Documents/python/hotspot/env/src/django-freeradius/django_freeradius/admin.py", line 6, in <module>
from .base.admin import (
File "/mnt/c/Users/myuser/Documents/python/hotspot/env/src/django-freeradius/django_freeradius/base/admin.py", line 9, in <module>
from openwisp_utils.admin import ReadOnlyAdmin, TimeReadonlyAdminMixin
ImportError: cannot import name 'ReadOnlyAdmin'
如果有人能告诉我这个错误的原因,我将不胜感激。
尝试安装openwisp-utils开发版:
pip install --upgrade http://github.com/openwisp/openwisp-utils/tarball/master