Skip to content

Instantly share code, notes, and snippets.

@voroninman
Last active January 2, 2016 02:09
Show Gist options
  • Save voroninman/8235161 to your computer and use it in GitHub Desktop.
Save voroninman/8235161 to your computer and use it in GitHub Desktop.
"""
Code snippet for changing Django user's password.
It implies that your unique user's field is email.
Start Django's shell and run code below:
cd /path/to/project
python manage.py shell
Or use built-in `changepassword` command:
cd /path/to/project
python manage.py changepassword USER_EMAIL
"""
from django.contrib.auth import get_user_model
user = get_user_model().objects.get(email__exact='USER_EMAIL')
user.set_password('NEW_PASSWORD')
user.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment