Is it possible to change the username?
I tried the following :-
user = User.objects.get(username = username)
user.username = newusername
user.save()
Nothing changes
I can change the username in the admin screen, but there are more than 100 where the client asked for different usernames to be used.
As you note (Django, change username), this was a mistake in your code - the code sample did not reflect your code. The code sample posted will in fact work to change a User
object's username:
user = User.objects.get(username = username)
user.username = newusername
user.save()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With