How to reset Django admin password?

前端 未结 21 1803
遥遥无期
遥遥无期 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:40

    if you forget your admin then you need to create new user by using

    python manage.py createsuperuser 
    

    and for password there is CLI command changepassword for django to change user password

    python manage.py changepassword 
    

    OR

    django-admin changepassword 
    

    OR Run this code in Django env

    from django.contrib.auth.models import User
    u = User.objects.get(username='john')
    u.set_password('new password')
    u.save()
    

提交回复
热议问题