我需要使用django-activity-stream,能够使用额外的"数据"真的很有帮助。字段,附加有关所列操作性质的额外信息。
根据文档,启动和运行起来应该非常简单:http://django-activity-stream.readthedocs.org/en/latest/data.html#custom-data
我安装了django-jsonfield,更改了设置以匹配,并尝试开始使用它,但这是我得到的错误
Unknown column 'actstream_action.data' in 'field list'
以下是更多信息,如果有帮助:
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/actstream/action/
Django Version: 1.8
Python Version: 2.7.8
Installed Applications:
('django_admin_bootstrapped',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'timezone_field',
'storages',
'mathfilters',
'adminactions',
'challenges',
'social',
'management',
'actstream',
'notifications')
Installed Middleware:
('ssl_redirect.middleware.SSLRedirectMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware',
'project.middlewares.TimezoneMiddleware',
'project.middlewares.CampaignsMiddleware',
'project.middlewares.AccountMiddleware')
Traceback:
File "/tmp/project/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/tmp/project/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
616. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/tmp/project/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
110. response = view_func(request, *args, **kwargs)
File "/tmp/project/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/tmp/project/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
233. return view(request, *args, **kwargs)
File "/tmp/project/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
34. return bound_func(*args, **kwargs)
File "/tmp/project/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
110. response = view_func(request, *args, **kwargs)
File "/tmp/project/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
30. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/tmp/project/lib/python2.7/site-packages/django/contrib/admin/options.py" in changelist_view
1638. media = self.media + formset.media
File "/tmp/project/lib/python2.7/site-packages/django/forms/formsets.py" in media
391. if self.forms:
File "/tmp/project/lib/python2.7/site-packages/django/utils/functional.py" in __get__
60. res = instance.__dict__[self.name] = self.func(instance)
File "/tmp/project/lib/python2.7/site-packages/django/forms/formsets.py" in forms
142. forms = [self._construct_form(i) for i in range(self.total_form_count())]
File "/tmp/project/lib/python2.7/site-packages/django/forms/formsets.py" in total_form_count
117. initial_forms = self.initial_form_count()
File "/tmp/project/lib/python2.7/site-packages/django/forms/models.py" in initial_form_count
567. return len(self.get_queryset())
File "/tmp/project/lib/python2.7/site-packages/django/db/models/query.py" in __len__
144. self._fetch_all()
File "/tmp/project/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
965. self._result_cache = list(self.iterator())
File "/tmp/project/lib/python2.7/site-packages/django/db/models/query.py" in iterator
238. results = compiler.execute_sql()
File "/tmp/project/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
829. cursor.execute(sql, params)
File "/tmp/project/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
79. return super(CursorDebugWrapper, self).execute(sql, params)
File "/tmp/project/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
File "/tmp/project/lib/python2.7/site-packages/django/db/utils.py" in __exit__
97. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/tmp/project/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
File "/tmp/project/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute
124. return self.cursor.execute(query, args)
File "/tmp/project/lib/python2.7/site-packages/MySQLdb/cursors.py" in execute
205. self.errorhandler(self, exc, value)
File "/tmp/project/lib/python2.7/site-packages/MySQLdb/connections.py" in defaulterrorhandler
36. raise errorclass, errorvalue
Exception Type: OperationalError at /admin/actstream/action/
Exception Value: (1054, "Unknown column 'actstream_action.data' in 'field list'")
答案 0 :(得分:0)
我刚遇到同样的问题。解决方案是重新运行迁移。就我而言,很容易说 - 我还没有任何数据。对于某些人来说,可能需要备份和恢复数据。
要还原actstream迁移:
python manage.py migrate actstream zero
然后:
python manage.py migrate actstream
当然,如果安装了django-jsonfield
,它就可以使用。