AttributeError:' NoneType'对象没有属性&action #with_auth_user_as_actor'

时间:2014-10-19 16:01:12

标签: python django

我正在尝试使用此处的指南django-activity-stream为我的项目配置django-activity-stream

我有模型User(django-contrib-auth),Article

如文档中所述,我使用语句

注册活动的模型
registry.register(User)
registry.register(Article)

执行runserver命令时,出现以下错误

Unhandled exception in thread started by <function wrapper at 0x7f3a680547d0>
Traceback (most recent call last):
  File "/home/xxxx/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 93, in wrapp
er
    fn(*args, **kwargs)
  File "/home/xxxx/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py",
 line 102, in inner_run
    self.validate(display_num_errors=True)
  File "/home/xxxx/local/lib/python2.7/site-packages/django/core/management/base.py", line 310, in 
validate
    num_errors = get_validation_errors(s, app)
  File "/home/xxxx/local/lib/python2.7/site-packages/django/core/management/validation.py", line 34
, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/home/xxxx/local/lib/python2.7/site-packages/django/db/models/loading.py", line 196, in get
_app_errors
    self._populate()
  File "/home/xxxx/local/lib/python2.7/site-packages/django/db/models/loading.py", line 75, in _pop
ulate
    self.load_app(app_name, True)
  File "/home/xxxx/local/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load
_app
    models = import_module('%s.models' % app_name)
  File "/home/xxxx/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import
_module
    __import__(name)
  File "/home/xxxx/local/lib/python2.7/site-packages/registration/models.py", line 15, in <module>
    User = get_user_model()
  File "/home/xxxx/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 127, in
 get_user_model
    user_model = get_model(app_label, model_name)
  File "/home/xxxx/local/lib/python2.7/site-packages/django/db/models/loading.py", line 271, in get
_model
    self._populate()
  File "/home/xxxx/local/lib/python2.7/site-packages/django/db/models/loading.py", line 75, in _pop
ulate
    self.load_app(app_name, True)
  File "/home/xxxx/local/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load
_app
    models = import_module('%s.models' % app_name)
  File "/home/xxxx/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import
_module
    __import__(name)
  File "/home/xxxx/maldio/maldio_project/links/models.py", line 115, in <module>
    registry.register(User)
  File "/home/xxxx/local/lib/python2.7/site-packages/actstream/registry.py", line 85, in register
    self[model_class] = setup_generic_relations(model_class)
  File "/home/xxxx/local/lib/python2.7/site-packages/actstream/registry.py", line 39, in setup_gene
ric_relations
    setattr(Action, attr_value, None)
AttributeError: 'NoneType' object has no attribute 'actions_with_auth_user_as_actor'

我错过了什么吗?

提前致谢

2 个答案:

答案 0 :(得分:1)

这是django-activity-stream版本0.5.1的问题。您可以通过删除0.5.1并安装0.5版本来修复此错误。

您可以在此处跟踪此错误:

https://github.com/justquick/django-activity-stream/issues/208

答案 1 :(得分:0)

看起来你&#34;用户&#34;变量中包含一个null对象,而不是一个有效的User对象。

用于创建&#34;用户&#34;的代码是什么?和&#34;文章&#34;您在所显示的函数中传递的对象?