Advertisement
Guest User

Untitled

a guest
Apr 12th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. def update_email_to_lower(apps, schema_editor):
  2. User = apps.get_model('userprofile', 'User')
  3. conflicts = 0
  4.  
  5. for user_update in User.objects.all():
  6. email = user_update.email
  7. if User.objects.filter(email__iexact=email).count() == 1:
  8. user_update.email = email.lower()
  9. user_update.save()
  10. else:
  11. conflicts += 1
  12. print conflicts
  13.  
  14. AttributeError: 'User' object has no attribute 'get_full_name'
  15.  
  16. def get_full_name(self):
  17. """Returns the full name for a user
  18. """
  19. if self.first_name and self.last_name:
  20. return u'{0} {1}'.format(
  21. self.first_name.strip(),
  22. self.last_name.strip()
  23. ).title()
  24.  
  25. elif self.first_name:
  26. return u'{0}'.format(self.first_name.strip()).title()
  27.  
  28. elif self.last_name:
  29. return u'{0}'.format(self.last_name.strip()).title()
  30.  
  31. else:
  32. return self.email.split('@')[0].lower()
  33.  
  34. class UserManager(BaseUserManager):
  35. use_in_migrations = True
  36. def create_user(self, email, password=None, is_active=True):
  37. .
  38. .
  39. .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement