Guest User

Untitled

a guest
Jan 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. user = User.objects.get(profile__facebook=fb_user.get('id'))
  2. # The actual code for getting the user branches off in a try catch, I believe...
  3. # so this just has to be reflected.
  4.  
  5. username = fb_user.get('username', '') or fb_user.get('id')
  6.  
  7. if user.username != username:
  8. try:
  9. user.username = username
  10. except UniqueBlabla:
  11. old_user = User.objects.get(username=username)
  12. old_user.username = old_user.profile.facebook_id
  13. old_user.save()
  14. user.username = username
  15. user.save()
Add Comment
Please, Sign In to add comment