Skip to content

Instantly share code, notes, and snippets.

@raprasad
Last active August 14, 2024 20:22
Show Gist options
  • 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()
@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