User creation fixes

This commit is contained in:
nikolark committed 2016-04-13 21:17:02 +02:00
1 parent 21c4f11ebc
commit 8a4a9fcb26
2 files changed
+5 -4

No files matched your search

+3 -2
View File
@@ -1,11 +1,12 @@
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.dispatch import receiver from django.dispatch import receiver
from main.models import UserProfile from main.models import UserProfile
@receiver(post_save, sender=get_user_model(), dispatch_uid='randomz') @receiver(post_save, sender=get_user_model())
def create_user_profile(sender, instance, created, **kwargs): def create_user_profile(sender, instance, created, **kwargs):
# Create a new UserProfile object when we create a new User. # Create a new UserProfile object when we create a new User.
if created: if created:
UserProfile.objects.create(user=instance) UserProfile.objects.create(user=instance)
+2 -2
View File
@@ -4,8 +4,8 @@ from django.db.models import Q
def format_username(firstname, lastname): def format_username(firstname, lastname):
first = firstname.lower().strip().replace(" ", "")[:6].encode('ascii', 'ignore') first = firstname.lower().strip().replace(" ", "")[:6].encode('ascii', 'ignore').decode('utf-8')
last = lastname.lower().strip().replace(" ", "")[:6].encode('ascii', 'ignore') last = lastname.lower().strip().replace(" ", "")[:6].encode('ascii', 'ignore').decode('utf-8')
return "{0}{1}".format(first, last) return "{0}{1}".format(first, last)