Horilla CRM lets each company pick a color theme, and the login page uses a default one. All of those themes are HorillaColorTheme rows in the database. If the table is empty, for example after a restore or a partial setup, the theme picker has nothing to offer. The create_default_themes management command fills it with Horilla CRM‘s built-in palettes. This post covers what it creates, when it skips work, and how it relates to the automatic seeding on migrate.
Usage
python manage.py create_default_themes
The command takes no arguments.
What it does
The command is in horilla/contrib/theme/management/commands/create_default_themes.py. It works in three steps:
- Checks for existing themes. If the HorillaColorTheme table already has any row, it prints “Themes already exist. Skipping creation.” and exits. It does not top up missing themes.
- Creates each built-in theme. It loops over THEMES_DATA in theme/utils.py and calls get_or_create on the theme name. This makes a run safe to repeat.
- Reports the result. It prints a line per theme, then the total created. A failure on one theme prints an error and the loop moves on to the next.
The built-in themes
THEMES_DATA defines 13 themes:
- Coral Red Theme (Default)
- Ocean Blue Theme
- Forest Green Theme
- Purple Professional Theme
- Slate Gray Theme
- Indigo Night Theme
- Sunset Orange Theme
- Crimson Wine Theme
- Teal Corporate Theme
- Amber Glow Theme
- Navy Steel Theme
- Rose Gold Theme
- Emerald Mint Theme
Each theme has a name and a description, such as “Professional and trustworthy feel with ocean-inspired blues”. It also has:
- A primary scale: primary_50 to primary_900.
- A secondary scale: secondary_50 to secondary_900.
- A dark scale: dark_25 to dark_600.
- A surface color: used for kanban and group-by backgrounds.
All colors are hex values. The model validates them with a regex, so a malformed value is rejected.
The default theme
Coral Red Theme (Default) is the only one with is_default=True. The login page uses it. The model keeps this safe: when you save a theme as default, HorillaColorTheme.save() turns the flag off on every other theme inside a transaction. There is also ensure_single_default(), which repairs data that somehow has more than one default. If no theme is marked default, get_default_theme() falls back to the Coral Red theme by name.
Automatic seeding on migrate
You usually do not need to run the command, because the theme app seeds itself. A post_migrate receiver in theme/signals.py creates the same themes when the app’s 0001_initial migration runs. It does nothing on later migrations, so a normal upgrade will not recreate themes you deleted.
Run the command yourself when:
- The themes table is empty because you deleted the rows, or restored a database that did not include them.
- You migrated in a way that skipped the initial migration’s post_migrate seeding, such as faking migrations.
- You are setting up a test or demo environment and want the palettes without a full migrate.
Good to know
- All or nothing. One existing theme, even a custom one, makes the command skip entirely. To restore a missing built-in theme, delete the custom rows first or create the theme from the admin.
- Name is the key. Themes are matched by their unique name. If you rename a built-in theme, a later seeding will create a fresh copy under the original name.
- Adding a built-in theme. Add a new dictionary to THEMES_DATA with the full set of color keys. It will be created on the next fresh seeding.
create_default_themes is a small safety-net command: it fills an empty themes table with Horilla’s 13 palettes and does nothing if any theme exists. Combined with the automatic seeding on the first migrate, it keeps the theme picker and the login page working on every install.