我正在尝试实现django-freeradius,但是当我在项目的urls.py中的urlspatters中写行*时,出现错误无法导入名称'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 的Django 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 runserver ()
时的完整错误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'
我很高兴有人可以给我这个错误的原因。
答案 0 :(得分:0)
尝试安装openwisp-utils的开发版本:
pip install --upgrade http://github.com/openwisp/openwisp-utils/tarball/master