2013-05-25 1 views
0

나는 django 1.5를 https://github.com/justquick/django-activity-stream과 함께 사용하고 있습니다. 나는Django django-activity-stream sql "data"열이 존재하지 않습니다?

action.send(request.user, verb="wrote", action_object=Message, target=Group) 

같은 action.send을했고,이 오류가 발생했습니다. 여기에 포스트 그레스가 기록되어

2013-05-25 08:51:46 PDT ERROR: column "data" of relation "actstream_action" 
does not exist at character 229 
2013-05-25 08:51:46 PDT STATEMENT: INSERT INTO "actstream_action" 
("actor_content_type_id", "actor_object_id", "verb", "description", 
"target_content_type_id", "target_object_id", "action_object_content_type_id", 
"action_object_object_id", "timestamp", "public", "data") VALUES (9, '2', 'wrote', NULL, 
14, '<property object at 0x25be3c0>', 22, '<property object at 0x25be3c0>', '2013-05-25 
15:51:46.693503+00:00', true, NULL) RETURNING "actstream_action"."id" 

내가 코드이 실행 믿습니다

def action_handler(verb, **kwargs): 
    """ 
    Handler function to create Action instance upon action signal call. 
    """ 
    from actstream.models import Action 

    kwargs.pop('signal', None) 
    actor = kwargs.pop('sender') 
    check_actionable_model(actor) 
    newaction = Action(
     actor_content_type=ContentType.objects.get_for_model(actor), 
     actor_object_id=actor.pk, 
     verb=unicode(verb), 
     public=bool(kwargs.pop('public', True)), 
     description=kwargs.pop('description', None), 
     timestamp=kwargs.pop('timestamp', now()) 
    ) 

    for opt in ('target', 'action_object'): 
     obj = kwargs.pop(opt, None) 
     if not obj is None: 
      check_actionable_model(obj) 
      setattr(newaction, '%s_object_id' % opt, obj.pk) 
      setattr(newaction, '%s_content_type' % opt, 
        ContentType.objects.get_for_model(obj)) 
    if settings.USE_JSONFIELD and len(kwargs): 
     newaction.data = kwargs 
    newaction.save() 

액션 모델 : action_handler에 따라서

class Action(models.Model): 
    actor_content_type = models.ForeignKey(ContentType, related_name='actor') 
    actor_object_id = models.CharField(max_length=255) 
    actor = generic.GenericForeignKey('actor_content_type', 'actor_object_id') 

    verb = models.CharField(max_length=255) 
    description = models.TextField(blank=True, null=True) 

    target_content_type = models.ForeignKey(ContentType, related_name='target', 
     blank=True, null=True) 
    target_object_id = models.CharField(max_length=255, blank=True, null=True) 
    target = generic.GenericForeignKey('target_content_type', 
     'target_object_id') 

    action_object_content_type = models.ForeignKey(ContentType, 
     related_name='action_object', blank=True, null=True) 
    action_object_object_id = models.CharField(max_length=255, blank=True, 
     null=True) 
    action_object = generic.GenericForeignKey('action_object_content_type', 
     'action_object_object_id') 

    timestamp = models.DateTimeField(default=now) 

    public = models.BooleanField(default=True) 

# below in models.py 
if actstream_settings.USE_JSONFIELD: 
    try: 
     from jsonfield.fields import JSONField 
    except ImportError: 
     raise ImproperlyConfigured('You must have django-jsonfield installed ' 
          'if you wish to use a JSONField on your actions') 
    JSONField(blank=True, null=True).contribute_to_class(Action, 'data') 

, 그것은 newaction.data = kwargs로있다. 데이터 속성이 db 테이블에 저장되는 이유는 무엇입니까?

답변

0

조치 모델에서 '데이터'입력란이 누락 된 것 같습니다.

가 아니면 - 당신이 원하지 않는 경우, 당신은이를 제거해야합니다

if settings.USE_JSONFIELD and len(kwargs): 
    newaction.data = kwargs 

왜 다만 JSONField가 https://github.com/bradjasper/django-jsonfield (또는 다른 곳)에서있는 데이터 필드를 만들? 당신의 settings.py에서 진정한

: 여기


당신이 당신은 라인

'USE_JSONFIELD'을 제거 할 수 있습니다 https://github.com/justquick/django-activity-stream/blob/master/actstream/models.py

if actstream_settings.USE_JSONFIELD: 
    try: 
     from jsonfield.fields import JSONField 
    except ImportError: 
     raise ImproperlyConfigured('You must have django-jsonfield installed ' 
           'if you wish to use a JSONField on your actions') 
    JSONField(blank=True, null=True).contribute_to_class(Action, 'data') 
+0

그래 난이 실현,하지만이 그것을 https://github.com/justquick/django-activity-stream – Derek

+0

K, THX에있는 정확한 방법입니다 때문에 일부러라고 가정 할 것 – Derek

+0

실제로 django-jsonfield가 필요한 것처럼 보입니다. https://github.com/justquick/django-activity-stream/blob/master/example_project/requirements.txt – ariddell

1

에서 놓치고있어 무엇 여기서 ACTSTREAM_SETTINGS을 (를) 지정했습니다.

ACTSTREAM_SETTINGS = { 
    # remove this 
    'USE_JSONFIELD': True, 
} 
관련 문제