User management à la Lino

This document explains how to get started with Lino's user management system. See users : user management for a more detailed documentation of the lino.modlib.users plugin.

A tested document

This is a tested document. The following instructions are used for initialization:

>>> from lino import startup
>>> startup('lino_book.projects.min1.settings.demo')
>>> from lino.api.doctest import *

Creating a root user

The most Linoish way to create a root user (or a set of demo users) is to run prep. This will reset the database to a virgin state and then load the demo fixture, which will create our well-known demo users Robin, Rolf, Romain, Rando, Rik, Ronaldo ... depending on your

If you don't want to reset your database, then you can write a script and run it with run. For example:

from import users
obj = users.User(username="root")


Note that the password field of a newly created user is empty, and the account therefore cannot be used to log in. If you create a new user manually using the web interface, you must click their ChangePassword action and set their password.

>>> u = users.User(username="test")
>>> u.full_clean()

Since we didn't set a password, Django stores a "non usable" password, and the User.check_password() method returns False:

>>> u.password  
>>> u.check_password('')
>>> u.has_usable_password()

When setting the password for a newly created user, leave the field Current password empty.

>>> ses = rt.login('robin')
>>> values = dict(current="", new1="1234", new2="1234")
>>> rv =, action_param_values=values)
>>> print(rv['message'])
New password has been set for test.

Note that a site administrator (a user having the lino.core.roles.SiteAdmin role) never needs to specify the current password when setting a new password for any user.