AttributeError: 'NoneType'对象没有属性'actions_with_auth_user_as_actor
我正在按照这里的指南配置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
看起来你的“User”变量里面有个空对象,而不是一个有效的用户对象。
你用来创建“User”和“Article”对象的代码是什么?你传递给你展示的函数的代码是怎样的?
1
这是关于django-activity-stream的0.5.1版本的问题。你可以通过卸载0.5.1版本,然后安装0.5版本来解决这个错误。
你可以在这里查看这个bug的详细信息:
https://github.com/justquick/django-activity-stream/issues/208