Is there any way to generate the username automatically. and I also need username while signing in so it must be unique-

```
class User(AbstractUser):
    username = models.CharField(max_length=50, unique=True, null= False, blank=False)
    email = models.EmailField(unique=True, null=False, blank=False)
    USERNAME_FIELD = 'username'
    def __str__(self):
        return "{}".format(self.email)

```

below is the code for user create serializer:

```
class UserSerializer(serializers.HyperlinkedModelSerializer):
profile = UserProfileSerializer(required=True)
username = serializers.CharField(label="username field",
                                     required=True, allow_null=False,
                                     allow_blank=False)

class Meta:
    model = User
    fields = ('id', 'username', 'email', 'first_name', 'last_name', 'password', 'profile')
    extra_kwargs = {'password': {'write_only': True}, 'first_name': {'required': True},
                    'last_name': {'required': True}}

def create(self, validated_data):
    profile_data = validated_data.pop('profile')
    password = validated_data.pop('password')
    try:
        if User.objects.filter(username__iexact=User(**validated_data).username).exists():
            raise serializers.ValidationError("username already exists")
    except Exception as e:
            error = {'message': ",".join(e.args) if len(e.args) > 0 else 'Unknown Error'}
            raise serializers.ValidationError(error)
    user = User(**validated_data)
    print(user.username)
    user.set_password(password)
    user.save()
    UserProfile.objects.create(user=user, **profile_data)
    return user

```

what changes should i make to generate username automatically?