After you install Horilla CRM and run the migrations, the database is empty. There is no user to log in with, and the login page has no sign-up link. Horilla ships with a management command for this step: create_horilla_user. This post covers what it does, how to run it interactively and non-interactively, and how to use it in Docker and CI.

What the command does

create_horilla_user lives in horilla/contrib/core/management/commands/create_horilla_user.py. When you run it, it:

  1. Collects a first name, last name, username, password, email, and phone number.
  2. Checks whether a user with that username already exists. If so, it prints a warning and exits without changing anything.
  3. Creates the user as a superuser with User.objects.create_superuser(…), using the custom horilla.auth.models.User model. The phone number is stored in the contact_number field.
  4. Makes sure a system user named Horilla Bot exists. It is created with a random UUID password, so nobody can log in as it.
  5. Prints a success message. If anything fails, it deletes the superuser it just created and raises a CommandError, so you are not left with a half-created account.

Running it interactively

python manage.py create_horilla_user

If you do not pass –first_name, the command prompts for each value in turn:

Enter first name: Jane
Enter last name: Doe
Enter username: jane.doe
Enter password:
Enter email: jane@example.com
Enter phone number: +1 555 0100
User “jane.doe” created successfully

The password is read with plain input(), so it is echoed on screen. Use the non-interactive form on shared screens.

Running it non-interactively

Pass –first_name and the command skips the prompts and reads every value from the arguments:

python manage.py create_horilla_user \
–first_name Jane \
–last_name Doe \
–username jane.doe \
–password ‘S3cure-Passw0rd!’ \
–email jane@example.com \
–phone ‘+1 555 0100’

ArgumentPurpose
–first_nameFirst name. Also switches off the prompts
–last_nameLast name
–usernameLogin username (must be unique)
–passwordPassword
–emailEmail address
–phoneStored as contact_number

Only –first_name triggers the switch. If you pass –username but forget –first_name, the command ignores your other arguments and prompts for everything.

Using it with Docker

The Horilla README runs the command inside the container after the stack is up:

make shell
python manage.py create_horilla_user

For an automated setup, run it in one line and read the values from the environment so the password does not land in your shell history:

docker-compose exec web python manage.py create_horilla_user \
–first_name “ADMINFIRST”–lastname”ADMIN_LAST” \
–username “ADMINUSER”–password”ADMIN_PASSWORD” \
–email “ADMINEMAIL”–phone”ADMIN_PHONE”

Because the command exits quietly when the username already exists, it is safe to leave in a provisioning script that may run more than once.

Things to know

  • It always creates a superuser. There is no flag for a regular user. Create ordinary users from the CRM interface after you have logged in as the admin.
  • Passwords on the command line are visible in process listings and shell history. Prefer environment variables or the interactive prompt for real deployments.
  • Run migrations first. The command needs the user table to exist.
  • Choose a strong password yourself. The command does not run Django’s password validators, so weak passwords are accepted.

create_horilla_user is the quickest way to get your first admin into a new Horilla CRM install. Run it with no arguments for a guided setup, or pass all the arguments for scripts and containers. Once it reports success, log in at your site URL with the username and password you chose.

This command also makes the initial setup easier for developers who need to configure Horilla in local environments, Docker containers, or automated deployment pipelines. Since it checks whether the username already exists, it can be included in repeatable setup scripts without creating duplicate users. Before using it in production, make sure the database migrations are complete and the admin credentials are stored securely. After logging in, you can configure the CRM and create additional users based on your organization’s requirements.

Share this article