我对django很疯狂,没有名为xxx的模块

时间:2013-04-22 19:45:58

标签: django

我不是美国人。我希望我能说清楚我发生了什么。

**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的模块”,我很困惑。

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

所以我只是去睡觉,希望有人可以帮我。

2 个答案:

答案 0 :(得分:1)

如果您选中PYTHONPATH,则/home/graduate/graduate需要位于路径上,才能导出coltrane个包。

您需要检查项目配置或将coltrane包移至/home/graduate

答案 1 :(得分:-1)

尝试使用网址模板标记而不使用“

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

这样

{% url userena_password_reset %}

有时调试器得到的消息不清楚。