Django应用访问时ViewDoesNotExist

问题描述:工作中的网站后台是基于django开发的,由基本的web服务,ftp服务,websocket服务,file服务等构成,使用了virtual env进行调试环境和运行环境的隔离。其中有一个功能是监测后台的cron jon(定时任务)的执行情况,今天我改了其他模块的代码后,引起了这个跟踪日志页面打不开,报错如下

ViewDoesNotExist at /tools/viewcrontabstatus/

Could not import cada.cadaadmin.misc.views. Error was: No module named pysvn
Request Method: GET
Request URL: http://127.0.0.1:8000/tools/viewcrontabstatus/
Django Version: 1.2.4
Exception Type: ViewDoesNotExist
Exception Value:
Could not import cada.cadaadmin.misc.views. Error was: No module named pysvn
Exception Location: C:\cada\lib\site-packages\django-1.2.4-py2.6.egg\django\core\urlresolvers.py in _get_callback, line 133
Python Executable: C:\cada\Scripts\python.exe
Python Version: 2.6.0
Python Path: ['C:\\cada\\cadaadmin\\cada\\cadaadmin', 'C:\\cada\\lib\\site-packages\\setuptools-0.6c11-py2.6.egg', 'C:\\cada\\lib\\site-packages\\pip-1.3.1-py2.6.egg', 'c:\\cada\\trunk', 'C:\\cada\\lib\\site-packages\\openpyxl-1.6.2-py2.6.egg', 'C:\\cada\\lib\\site-packages\\xlwt-0.7.5-py2.6.egg', 'C:\\cada\\lib\\site-pac....................]

报错只是指出有些模块有问题,但是并没有指明问题代码的位置,很头痛

 

环境工具:windows XP python2.6  Django1.2.4  virtualenv1.10.0

 

解决过程:1. 查看views.py和urls.py文件,查看/tools/viewcrontabstatus/路径在路由中是否配置正常,是否有相应的view function 处理响应,发现都正常

 

                   2. 接下来,进cmd的python shell,执行

>>>import cada.cadaadmin.misc.views

发现报错如下

Traceback (most recent call last):
  File "", line 1, in
  File "cada\cadaadmin\misc\views.py", line 13, in
    from cada.cadaadmin.cadacv.models import CadaCrontabStatus
    ................
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.mysql' isn't an
 available database backend.
Try using django.db.backends.XXX, where XXX is one of:
    'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name utils

这些错误都是跟django环境相关的,并没有暴露Error was: No module named pysvn的问题在哪里

                  

                   3. 退出python shell,使用python manage.py shell进入django shell

>>>import cada.cadaadmin.misc.views

报错如下
Traceback (most recent call last):
  File "", line 1, in
  File "c:\cada\lib\site-packages\cadaadmin-0.1-py2.6.egg\cada\cadaadmin\misc\vi
ews.py", line 17, in
    from cada.bin.tools.macro.svn import SVN
  File "C:\cada\lib\site-packages\cada.data-0.1-py2.6.egg\cada\bin\tools\macro\s
vn.py", line 11, in
    import pysvn
ImportError: No module named pysvn

这里的日志就很详细,我想起来在vituralenv调试环境里面(C:\cada\cadadata\cada\bin\tools\macro\svn.py)的svn.py如下

...
try:
    import pysvn
except:
    pass

...

而运行环境里面(C:\cada\Lib\site-packages\cada.data-0.1-py2.6.egg\cada\bin\tools\macro\svn.py)如下

...

import pysvn

...

原来是因为目前的环境里面没有安装pysvn造成的,只不过因为不重要,所以之前我加了try...except...忽略了这个问题,今天又重新装了一遍运行环境,导致这里还原了,造成问题。

你可能感兴趣的:(日常应用)