Ask Your Question
2

Error when posting - Can't find personal group (into existing site Django 1.8)

asked 2016-06-28 14:09:37 -0600

albrnick gravatar image

updated 2016-06-30 05:09:04 -0600

Evgeny gravatar image

Hello!

I'm trying to add askbot into an existing site running Django 1.8. I've just got things up and running, but ran into an error when trying out my first test post. It bombs on the last line here:

def user_get_personal_group(self):
  group_name = format_personal_group_name(self)
  return Group.objects.get(name=group_name)  # bombs here with Group.DoesNotExist error

Looking around, it looks like the function 'add_user_to_personal_group' wasn't called because the user model was never saved/existed before I integrated askbot. I'm tempted to change the code to:

def user_get_personal_group(self):
  group_name = format_personal_group_name(self)
  try:
    return Group.objects.get(name=group_name)  
  except Group.DoesNotExist:
    add_user_to_personal_group( None, self, True ) # Add the group if not here.
    return Group.objects.get(name=group_name)

But don't know if that is the right way to go about this. Would there be a better way for me to do?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-06-30 05:08:31 -0600

Evgeny gravatar image

Made a similar change in commit (https://github.com/ASKBOT/askbot-deve...):

def user_get_personal_group(self):
      group_name = format_personal_group_name(self)
      try:
          #may be absent if askbot is added to pre-existing site
          return Group.objects.get(name=group_name)
      except Group.DoesNotExist:
          self.join_default_groups()
          return Group.objects.get(name=group_name)
edit flag offensive delete link more

Comments

Oh perfect! Thanks! = ) I'll pull the latest!

albrnick gravatar imagealbrnick ( 2016-06-30 08:33:43 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-06-28 14:09:03 -0600

Seen: 159 times

Last updated: Jun 30 '16