Django Taggit - AttributeError:无法设置属性

时间:2017-01-12 16:33:50

标签: python django postgresql attributeerror django-taggit

昨天我安装了PostgreSQL作为我正在开发的网站的数据库。 安装完成后,计算机重新启动。

出了什么问题? 我丢失了所有的环境变量(我使用的是Windows 10)。所以我不得不重新添加python到路径。

之后我创建了db我替换了settings.py上的数据。 我运行网站,但它给出了一个错误。所以我安装了psycopg2让postgres使用django。 没办法。

我决定暂时回到sqlite3,所以我编辑了settings.py并运行了网站。 错误告诉我没有名为Taggit的应用程序。 (???)这不正常。我安装了它,一切正常。我重新安装了它(版本0.17.1)。

我不知道如果这些事件是连通的...这就是我告诉你一切的原因。 现在: 在我使用django Taggit的每一个项目中,我都会收到同样的错误(即使是在几个月内我没有打开的那个)......

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000181AA17DAE8>
Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Python35\lib\site-packages\django\core\management\commands\runserver.py", line 113, in inner_run
    autoreload.raise_last_exception()
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "C:\Python35\lib\site-packages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Python35\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Python35\lib\site-packages\django\__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Python35\lib\site-packages\django\apps\registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "C:\Python35\lib\site-packages\django\apps\config.py", line 199, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\Users\Marco\Documents\Progetti\GiemmeLift\website\blog\models.py", line 21, in <module>
    class Post(models.Model):
  File "C:\Users\Marco\Documents\Progetti\GiemmeLift\website\blog\models.py", line 34, in Post
    tags = TaggableManager()
  File "C:\Python35\lib\site-packages\taggit\managers.py", line 285, in __init__
    rel = TaggableRel(self, related_name, self.through, to=to)
  File "C:\Python35\lib\site-packages\taggit\managers.py", line 55, in __init__
    self.to = to
AttributeError: can't set attribute

我尝试重新安装django-taggit但没有改变。

你能帮我理解为什么吗?

1 个答案:

答案 0 :(得分:5)

我遇到了同样的问题,安装了最新版本的django-taggit并且有效。