Dealing with Users¶
Adding New Users¶
For now Le Ménage doesn’t support adding new users in UI. Instead, we use the good ol’ Python shell.
Go to the project directory and start the Django shell.
cd menage
./manage.py shell
Now import Le Ménage models. CustomUser model overrides the built-in User model.
from core import models
Now you can safely create as many user as your heart desires, using the create_user() method of the original class.
models.CustomUser.objects.create_user("username", "user@email.org", "passwd")
It is the best way to ensure the password gets hashed the right way and it doesn’t get stored as a string, which would break the authentification entirely.
Changing User Password¶
As you may have guessed, Le Ménage doesn’t support changing user passwords in UI either. Instead, we’re going to do a bit of Python shell magic again.
Go to the project directory and start the Django shell.
cd menage
./manage.py shell
Now import Le Ménage models. CustomUser model overrides the built-in User model.
from core import models
Now we can obtain the user instance and set the password.
user = models.CustomUser.objects.all().filter(username="username")[0]
user.set_password('newpasswd')
user.save()