How to reset Django admin password?

前端 未结 21 1703
遥遥无期
遥遥无期 2020-12-12 08:39

I am using Django (version 1.3) and have forgotten both admin username and password. How to reset both?

And is it possible to make a normal user into admin, and then

相关标签:
21条回答
  • 2020-12-12 09:15

    Just type this command in your command line:

    python manage.py changepassword yourusername
    
    0 讨论(0)
  • 2020-12-12 09:18
    python manage.py changepassword <user_name>
    

    see docs

    0 讨论(0)
  • 2020-12-12 09:19

    I think,The better way At the command line

    python manage.py createsuperuser

    0 讨论(0)
  • 2020-12-12 09:20

    The best way is to just go to your terminal and type

    python manage.py createsuperuser
    

    and insert another password and user name again but u will lost some of your profile that u have created before in most cases.

    0 讨论(0)
  • 2020-12-12 09:22

    You may try through console:

    python manage.py shell
    

    then use following script in shell

    from django.contrib.auth.models import User
    User.objects.filter(is_superuser=True)
    

    will list you all super users on the system. if you recognize yur username from the list:

    usr = User.objects.get(username='your username')
    usr.set_password('raw password')
    usr.save()
    

    and you set a new password (:

    0 讨论(0)
  • 2020-12-12 09:25

    You may try this:

    1.Change Superuser password without console

    python manage.py changepassword <username>
    

    2.Change Superuser password through console

    0 讨论(0)
提交回复
热议问题