How to reset the Django admin and superuser password

preview_player
Показать описание
How to reset the Django admin and superuser password

Find your username:

Start the shell
____________________
_______________________

We can find out what usernames are used for admin with this:
________________________________________________________________________
________________________________________________________________________

You will now get a result similar to this:
__________
['p_admin']
___________

If you get multiple results, you have multiple superuser. Pick the one that you want to change the password from.

Reset your Django admin password:

Open up the Django shell if you haven't yet. Then enter this:
_________________________________________________
def reset_password(u, password):
try:
except:
return "User could not be found"
return "Password has been changed successfully"
________________________________________________

That's the function we will use to change the password of a user. Up next, you can simply do:
__________________________________
reset_password('username', 'password')
____________________________________

Obviously, change the username with the username of your superuser account and change the password with something you want to use as a password.

Let me know in the comments below if you still need help with resetting your Django admin password.

I used hp laptop with windows 8.1 installed and Icecream Screen Recorder for this video.

If you found this video useful please sub to me.
Рекомендации по теме
Комментарии
Автор

Overally, It is just a improved version of this video :)

suhailxeaser
Автор

Thanks for this. Really helped me out.

rogueDukakis
Автор

it didn't work for me. couldn't generate my username

matthewgift
Автор

when i try to login it says site can't be reached and the server automatically breaks please help and when i open it in private mode or clear history then it opens admin login but when i press login it says site can't be reached

mayur
Автор

didnt understand the part you indented the block in try: and then the followig line

ezevalentine
Автор

hello the error i am getting is
reset_password not defined
anything different i can do

abhijeetkadam