我已经在CentOS 7.0版本上安装了Django。Django CentOS 7 - 无法导入姓名Col
#yum install python-pip
#pip install django
#cd /home
#django-admin startproject mysite
#cd mysite
#python manage.py runserver 0.0.0.0:8000
,当我去http://domain.com:8000在网络浏览器,我看到下面的错误。
ImportError at/
cannot import name Col
Request Method: GET
Request URL: http://domain.com:8000/
Django Version: 1.6.10
Exception Type: ImportError
Exception Value:
cannot import name Col
Exception Location: /usr/lib/python2.7/site-packages/django/contrib/contenttypes/fields.py in <module>, line 13
Python Executable: /usr/bin/python
Python Version: 2.7.5
应该在CentOS 6.3的工作,但我认为这是在CentOS 7.0
我看着fields.py文件
不同============== ==============================
from __future__ import unicode_literals
from collections import defaultdict
from django.core import checks
from django.core.exceptions import ObjectDoesNotExist
from django.db import connection
from django.db import models, router, transaction, DEFAULT_DB_ALIAS
from django.db.models import signals, FieldDoesNotExist, DO_NOTHING
from django.db.models.base import ModelBase
from django.db.models.fields.related import ForeignObject, ForeignObjectRel
from django.db.models.related import PathInfo
from django.db.models.sql.datastructures import Col
from django.contrib.contenttypes.models import ContentType
from django.utils import six
from django.utils.deprecation import RenameMethodsBase, RemovedInDjango18Warning
从django.utils.encoding进口smart_text,python_2_unicode_compatible
就是这样。
请将您的Django码。尤其是导入“Col”的部分。 – 2015-04-04 03:19:29
@KlausD。我更新了Django代码。 – Jake 2015-04-04 11:30:34