Skip to content

Instantly share code, notes, and snippets.

@ktaranov
Forked from raprasad/change_password.md
Created July 23, 2021 12:04
Show Gist options
  • Save ktaranov/e1bf9c39bee4423778c6a3c236adc682 to your computer and use it in GitHub Desktop.
Save ktaranov/e1bf9c39bee4423778c6a3c236adc682 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment