First time here? Check out the FAQ!
2

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

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!

albrnick's avatar
65
albrnick
asked 2016-06-28 14:09:37 -0600
Evgeny's avatar
13.2k
Evgeny
updated 2016-06-30 05:09:04 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

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)
Evgeny's avatar
13.2k
Evgeny
answered 2016-06-30 05:08:31 -0600
edit flag offensive 0 remove flag delete link

Comments

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

albrnick's avatar albrnick (2016-06-30 08:33:43 -0600) edit
add a comment see more comments