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]
- [Answered ]-Django template – p tag is closed for no reason
- [Answered ]-How to override handle method in SelfHandlingForm in OpenStack horizon?
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]
- [Answered ]-Django unexpected IntegrityError with PostgreSQL
- [Answered ]-Is this a problem with the Django tutorial or a package problem, or is it me?
- [Answered ]-Django REST Framework: Purpose of CreateOnlyDefault
Source:stackexchange.com