在/ admin /导入错误

时间:2014-09-16 08:02:15

标签: python django django-tables2

我似乎有一段时间的问题,现在我无法理解。

在尝试进入我的Django管理站点时,我在/ admin / no模块命名工具时不断收到导入错误。问题是,我有一个名为tools的应用程序,但是从项目中删除了它。但我仍然在管理员处获得导入错误,没有名为tools的模块。在stackoverflow上进行了一些谷歌搜索后,我发现一篇文章建议删除所有pyc文件,因为它们包含仍在引用的旧数据,这是有道理的。但是在删除了我在当前项目目录中看到的每个pyc文件后,我仍然会收到错误。

这是奇怪的地方。

我正在使用django_tables2。我还有一个跟踪书籍信息的书籍应用程序。我为books应用程序创建了一个表类,并将表列指定为链接列。在查看图书应用程序的索引页面时,我在/ books / no模块命名工具中获得导入错误,但书籍应用程序中根本没有对工具的引用?我在/ admin / no模块命名工具时遇到相同的错误导入错误。但是,如果我将书籍应用程序表类中的LinkColumn更改回正常列,只需更改详细名称,错误就会随着书籍应用程序索引页面消失,但仍然存在于管理员?老实说,我不知道这里发生了什么。

编辑:即使在启动新的工具应用程序并在admin.py中注册它也会出现同样的错误。我唯一可以想到它的路径错误,但如果能找到同一目录中的其他应用程序又怎么样?为什么?

如果需要,我非常愿意发布任何代码,但我不知道从哪里开始寻找。

Traceback:
File "django/core/handlers/base.py" in get_response
  114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "django/contrib/admin/sites.py" in wrapper
  215. return self.admin_view(view, cacheable)(*args, **kwargs)
File "django/utils/decorators.py" in _wrapped_view
  99. response = view_func(request, *args, **kwargs)
File "django/views/decorators/cache.py" in _wrapped_view_func
  52. response = view_func(request, *args, **kwargs)
File "django/contrib/admin/sites.py" in inner
  198. return view(request, *args, **kwargs)
File "django/views/decorators/cache.py" in _wrapped_view_func
  52. response = view_func(request, *args, **kwargs)
File "django/contrib/admin/sites.py" in index
  358. model_dict['admin_url'] = reverse('admin:%s_%s_changelist' % info, current_app=self.name)
File "django/core/urlresolvers.py" in reverse
  480. app_list = resolver.app_dict[ns]
File "django/core/urlresolvers.py" in app_dict
  310. self._populate()
File "django/core/urlresolvers.py" in _populate
  285. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "django/core/urlresolvers.py" in callback
  229. self._callback = get_callable(self._callback_str)
File "django/utils/functional.py" in wrapper
  32. result = func(*args)
File "django/core/urlresolvers.py" in get_callable
  100. not module_has_submodule(import_module(parentmod), submod)):
File "django/utils/importlib.py" in import_module
  40. __import__(name)

Exception Type: ImportError at /admin/
Exception Value: No module named tools

1 个答案:

答案 0 :(得分:1)

对于任何偶然发现这个问题的人:

之前我遇到过这样的错误,通过在urls.py中评论网址模式来实现它。您的某个视图中可能会有导入广告的行为,并且由于您的管理面板会导入您的网址模式中的所有视图,请尝试逐一评论它们,您可能会发现罪魁祸首。

相关问题