Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def update_email_to_lower(apps, schema_editor):
- User = apps.get_model('userprofile', 'User')
- conflicts = 0
- for user_update in User.objects.all():
- email = user_update.email
- if User.objects.filter(email__iexact=email).count() == 1:
- user_update.email = email.lower()
- user_update.save()
- else:
- conflicts += 1
- print conflicts
- AttributeError: 'User' object has no attribute 'get_full_name'
- def get_full_name(self):
- """Returns the full name for a user
- """
- if self.first_name and self.last_name:
- return u'{0} {1}'.format(
- self.first_name.strip(),
- self.last_name.strip()
- ).title()
- elif self.first_name:
- return u'{0}'.format(self.first_name.strip()).title()
- elif self.last_name:
- return u'{0}'.format(self.last_name.strip()).title()
- else:
- return self.email.split('@')[0].lower()
- class UserManager(BaseUserManager):
- use_in_migrations = True
- def create_user(self, email, password=None, is_active=True):
- .
- .
- .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement