更新时Django Admin问题,Path必须是完全限定的

时间:2017-05-24 13:16:56

标签: django python-2.7 django-1.8

我正在通过每个版本升级一个大型Django项目,希望能达到1.11。

但是我在访问某些页面时遇到了问题。例如,我无法访问/ admin /面板。我目前在1.8.18及更高版本上遇到此问题。

我的网址文件与此类似:

from django.contrib import admin
urlpatterns = [ 
                ...

               url(r'^admin/', include(admin.site.urls)), 
               #Tried this:
               # url(r'^admin/', admin.site.urls),
 ]

Out吐出一条非常无益的痕迹,导致:

ImportError: Could not import 'public_private_controller'. The path must be fully qualified.

据我了解,在django的未来版本(超过1.9)中,不再允许使用字符串URL,并且必须将URL功能路径设置为类似于上述代码中的注释掉版本。但这是1.8,我不确定我的问题在哪里。我还没有从追踪中获得好的提示:

完整堆栈跟踪:

Internal Server Error: /admin/
Traceback (most recent call last):
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 254, in wrapper
    return self.admin_view(view, cacheable)(*args, **kwargs)
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 233, in inner
    return view(request, *args, **kwargs)
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 427, in index
    model_dict['admin_url'] = reverse('admin:%s_%s_changelist' % info, current_app=self.name)
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 549, in reverse
    app_list = resolver.app_dict[ns]
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 351, in app_dict
    self._populate()
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 307, in _populate
    for name in pattern.reverse_dict:
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 337, in reverse_dict
    self._populate()
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 325, in _populate
    lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 246, in callback
    self._callback = get_callable(self._callback_str)
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/utils/lru_cache.py", line 101, in wrapper
    result = user_function(*args, **kwds)
  File "/Users/rob/src/dm_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 102, in get_callable
    lookup_view)
ImportError: Could not import 'public_private_controller'. The path must be fully qualified.

任何暗示导致这种情况的原因是什么?最好的猜测是我的一个软件包要么已过时,要么使用与1.8不兼容的较新版本。但所有跟踪似乎都是直接来自django本身。

0 个答案:

没有答案