1

我不是美国人。我希望我能清楚地表达我发生的事情。

**Django wrong log:**
    ImportError at /accounts/signin/
    No module named coltrane
    Request Method: GET 
    Request URL: http://abc.com:8080/accounts/signin/ 
    Django Version: 1.4.1 
    Exception Type: ImportError 
    Exception Value: No module named coltrane 
    Exception Location: /usr/lib/python2.6/site-packages/django/utils/importlib.py in import_module, line 35 
    Python Executable: /usr/bin/python 
    Python Version: 2.6.6 
    Python Path: ['/home/graduate',
     '/usr/lib64/python26.zip',
     '/usr/lib64/python2.6',
     '/usr/lib64/python2.6/plat-linux2',
     '/usr/lib64/python2.6/lib-tk',
     '/usr/lib64/python2.6/lib-old',
     '/usr/lib64/python2.6/lib-dynload',
     '/usr/lib64/python2.6/site-packages',
     '/usr/lib64/python2.6/site-packages/PIL',
     '/usr/lib64/python2.6/site-packages/gtk-2.0',
     '/usr/lib/python2.6/site-packages',
     '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info'] 
    Server time: 星期二, 23 四月 2013 11:27:33 +0800 

    Error during template rendering
    In template /usr/lib/python2.6/site-packages/userena/templates/userena/signin_form.html, error at line 29

    No module named coltrane
    19     </p>

    20     {% else %}

    21     <p>

    22     {{ field.label_tag }}

    23     {{ field }}

    24     </p>

    25     {% endif %}

    26     {% endfor %}

    27   </fieldset>

    28   <input type="submit" value="{% trans "Signin" %}" />

    29   <p class="forgot-password"><a href="{% url 'userena_password_reset' %}" title="{% trans 'Forgot your password?' %}">{% trans "Forgot your password?" %}</a></p>

    30   {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}

    31 </form>

    32 {% endblock %}

    33  

但我的设置文件:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',
    'django.contrib.markup',
    'django.contrib.comments',
    'userena',
    'easy_thumbnails',
    'guardian',
    'graduate.coltrane',
    'graduate.accounts',
)

我的项目目录:

[root@fuwuqi graduate]# pwd
/home/graduate/graduate
[root@fuwuqi graduate]# ls
accounts  coltrane  __init__.py  __init__.pyc  settings.py  settings.pyc  templates  urls.py  urls.pyc  wsgi.py  wsgi.pyc
[root@fuwuqi graduate]# 

我很疯狂,为什么 django 告诉我“没有名为 coltrane 的模块”,我很困惑。

这个问题花了我很长时间直到现在。

所以我只是去睡觉,希望有人能帮我一把。

4

2 回答 2

1

如果您选中PYTHONPATH,则/home/graduate/graduate需要在路径上才能使coltrane包可导入。

您需要检查您的项目配置或将coltrane包移动到/home/graduate.

于 2013-04-22T19:58:52.653 回答
-1

尝试使用不带 ''的url 模板标签

 29   <p class="forgot-password"><a href="{% url 'userena_password_reset' %}"

这边走

{% url userena_password_reset %}

有时你从调试器得到的信息不是很清楚。

于 2013-04-22T20:32:17.623 回答