首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向Django活动流添加JSON字段会导致未知列错误,即使安装了django-jsonfield也是如此

向Django活动流添加JSON字段会导致未知列错误,即使安装了django-jsonfield也是如此
EN

Stack Overflow用户
提问于 2015-07-28 09:45:45
回答 1查看 352关注 0票数 1

我需要使用django-activity-stream,如果能够使用额外的"data“字段来附加有关所列操作的性质的额外信息,那将非常有帮助。

根据文档,它的启动和运行应该非常简单:http://django-activity-stream.readthedocs.org/en/latest/data.html#custom-data

我安装了django-jsonfield,更改了相应的设置,并尝试开始使用它,但得到的错误如下

Unknown column 'actstream_action.data' in 'field list'

以下是更多信息,以防对您有所帮助:

代码语言:javascript
复制
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'")
EN

回答 1

Stack Overflow用户

发布于 2016-10-03 22:51:29

我刚刚遇到了同样的问题。解决方案是重新运行迁移。在我的情况下,这很容易说-我还没有任何数据。对于某些人来说,数据备份和恢复可能是必要的。

要恢复actstream迁移:python manage.py migrate actstream zero,然后:python manage.py migrate actstream

当然,如果您安装了django-jsonfield,它就可以工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31666098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档