我已經在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