TemplateView神秘不可用

时间:2011-10-03 19:00:03

标签: django django-templates

我有两个主机,我已经安装了django 1.3.1,我看到了不同的行为:

主持人1:

jeff@nantes:purple $ python --version
Python 2.6.5
jeff@nantes:purple $ python manage.py shell
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.views.generic import TemplateView
>>> 

在主持人2上:

jeff@s8:~/purpledom$ python --version
Python 2.6.6
jeff@s8:~/purpledom$ python manage.py shell
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from django.views.generic import TemplateView
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)

/home/jeff/purpledom/<ipython console> in <module>()

ImportError: cannot import name TemplateView

In [2]: 

看起来django / views / generic / base.py以相同的方式定义了TemplateView。 python中的次要版本更改似乎是一个红色的鲱鱼(但我不能证明它)。

有什么建议吗?

当然,有错误的是我的制作主持人。 :(

1 个答案:

答案 0 :(得分:1)

你是对的,运行不同版本的Python与此无关,特别是当它只是安全性/错误修复版本的差异时。

我最好的猜测是,即使您可能同时安装了Django 1.3,生产服务器仍然使用较小的版本。尝试运行django-admin.py --version,看看会出现什么。我打赌它不会是1.3。删除Python路径中的所有旧Django鸡蛋或文件夹,然后重试。

相关问题