Skip to content

Instantly share code, notes, and snippets.

@raprasad
Last active March 15, 2024 17:21
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save raprasad/650ae3cbf193590e5d289e8919b7217b to your computer and use it in GitHub Desktop.
Save raprasad/650ae3cbf193590e5d289e8919b7217b to your computer and use it in GitHub Desktop.
django user; change password from shell

update django password

general changes

To use in dev environments

  • after python manage.py shell
from django.contrib.auth.models import User

# dev environ with only a few users
l = User.objects.all() 

# show user list
print(l)

# get the 1st user
u = l[0]

# set the password
u.set_password('123') # for dev
u.save()

with custom user

  • Only differs by initial import on 1st line
from tworaven_apps.raven_auth.models import User

# dev environ with only a few users
l = User.objects.all() 

# show user list
print(l)

# get the 1st user
u = l[0]

# set the password
u.set_password('123') # for dev
u.save()
@Izuguchi
Copy link

Thank you very much!!

@Luis1Jovany
Copy link

Thanks! This helped me.

@Pragyanshu-rai
Copy link

Thank you very much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment