[Answered ]-How i can split a Email in Django

1👍

current_user = request.user #current_user.split is not working!

It will not work becouse request.user is a User object not a String you can’t split user object instead you can do like this to split user’s email.

@login_required(login_url='login') 
def Example_dashboard(request):
    form = MembersForm()
    current_user = request.user
    name = current_user.email.split('@')[0] # or .split('.example@hotmail.de')[0]
    context = {'form': form, "cunrrent_user": current_user}
    return render(request, 'example_dashboard.html', context)

0👍

You can make this possible by using split method

After current_user = request.user, Try this:

current_user = current_user.split('@')[0]

0👍

Try this solution. Because of request.user is None. That’s why you can’t split an email.

current_user = request.POST.get(‘email’)
user_name = current_user.split('@')[0]

Leave a comment