First time here? Check out the FAQ!
0

'AnonymousUser' object has no attribute 'get_groups'

After enable user group, for anonymous user, it throws error below. Any idea?

askbot/models/question.py in get_latest_revision

posts_filter['groups__in'] = user.get_groups()

johnli's avatar
28
johnli
asked 2014-11-22 00:31:06 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1
 #  if user and askbot_settings.GROUP_ENABLED: (askbot/models/question.py line 745)
 #  this line throws 'AnonymousUser' object has no attribute 'get_groups' exception for AnonymousUser. See fix below.
 # user passed to this function could be actual user object, Anonymous user which doesnt have get_group(), or None

  if user and askbot_settings.GROUPS_ENABLED:
        if user.is_authenticated():
        #get post with groups shared with having at least 
        #one of the user groups
        #of those posts return the latest revision
            posts_filter['groups__in'] = user.get_groups()
johnli's avatar
28
johnli
answered 2014-11-23 21:40:05 -0600, updated 2014-11-29 16:14:35 -0600
edit flag offensive 0 remove flag delete link

Comments

Thanks, committed this change to the master branch.

Evgeny's avatar Evgeny (2014-11-29 17:27:42 -0600) edit
add a comment see more comments