Every Horilla CRM module follows a standard structure, with an apps.py file based on AppLauncher, along with menu.py, registration.py, signals.py, urls.py, templates, static files, and locale folders. Creating these files manually takes time and increases the chance of missing something.

Horilla provides the start_horilla_app management command to generate this initial structure automatically. This guide explains how to use the command, the options it supports, the files it creates, and the steps required to start developing your new module.

Basic usage

Run the following command from your Horilla CRM project directory:

python manage.py start_horilla_app my_module

The command creates a new app named my_module in the current directory.

The app name must start with a letter or underscore and contain only letters, numbers, and underscores. For example, my_module is valid, while my-module and 1module are invalid. Invalid names are rejected with an error message.

To create the app in a different directory, use the –directory option or its short form, -d:

python manage.py start_horilla_app my_module –directory horilla_crm

This creates the app directory at horilla_crm/my_module/.

Note: If you create the app inside another Python package, check the generated AppConfig.name and the corresponding INSTALLED_APPS entry. They must match the app’s importable Python package path.

Available options

The command supports the following arguments and options:

OptionShort formPurpose
app_name—Name of the new app. Required.
–directory-dParent directory in which to create the app.
–languages-lLanguage codes for which locale folders should be created, such as -l en fr de.
–project-pAccepted by the command, but currently has no effect.

If you omit –languages, the command uses the languages configured in settings.LANGUAGES and creates the corresponding locale directories. It also prints a notice indicating the number of languages processed.

For example, to create locale directories for English, French, and German, run:

python manage.py start_horilla_app my_module –languages en fr de

The –project option is accepted for compatibility, but it does not currently change the generated app structure or behavior.

What the command generates

For an app named my_module, the generated structure looks like this:

my_module/
├── init.py
├── version.py
├── admin.py
├── apps.py
├── filters.py
├── forms.py
├── menu.py
├── models.py
├── registration.py
├── signals.py
├── tests.py
├── urls.py
├── views.py
├── migrations/
│ └── init.py
├── templates/
├── templatetags/
│ └── init.py
├── static/
│ └── my_module/
│ └── assets/
│ ├── icons/
│ └── js/
└── locale/
├── en/
│ └── LC_MESSAGES/
└── …

The locale directories shown above are examples; the actual directories depend on the configured or supplied language codes.

The generated files provide a starting point for integrating the new app into Horilla. The most important ones are explained below.

apps.py

The command generates an AppLauncher subclass with the basic app configuration:

from horilla.apps import AppLauncher
from horilla.utils.translation import gettext_lazy as _




class MyModuleConfig(AppLauncher):
    default = True
    default_auto_field = "django.db.models.BigAutoField"
    name = "my_module"
    verbose_name = _("My Module")


    url_prefix = "my_module/"
    url_module = "my_module.urls"
    url_namespace = "my_module"


    auto_import_modules = [
        "registration",
        "signals",
        "menu",
    ]

The class name and verbose name are generated from the app name. For example, my_module becomes MyModuleConfig, and its display name becomes “My Module”.

The AppLauncher configuration connects the app to Horilla’s application-loading process.

  • name identifies the Python app package.
  • verbose_name provides a human-readable name.
  • url_prefix defines the URL prefix used to mount the app’s routes.
  • url_module identifies the app’s URL configuration.
  • url_namespace provides the namespace used when reversing named URLs.
  • auto_import_modules lists modules that Horilla imports during app initialization.

Because registration, signals, and menu are included in auto_import_modules, their registration code and signal handlers can be loaded automatically when the app initializes.

Horilla handles URL mounting through AppLauncher, so a separate change to the project’s root urls.py is not normally required for this app’s URL configuration.

menu.py

The generated menu.py file includes imports for Horilla’s menu registration helpers:

  • floating_menu
  • main_section_menu
  • sub_section_menu
  • settings_menu
  • my_settings_menu

These helpers let you register navigation items, quick-create actions, and settings entries.

After generating the app, add the relevant menu registrations to make your module accessible through Horilla’s interface.

registration.py

The generated registration.py file imports register_feature and register_model_for_feature.

These functions support integration with Horilla’s feature-registration system. Depending on the features you configure, you can register models for capabilities such as global search, import, and export.

For example, after defining a model, you can register it for the supported features you need. The registration must reference the correct app label and model name.

urls.py

The generated urls.py file defines the app namespace and an initially empty urlpatterns list.

Add your URL patterns here as you develop the module’s views.

For example:

from horilla.urls import path
from . import views


app_name = "my_module"


urlpatterns = [
    # Add your URL patterns here.
]

This is a starting example. Add the actual view imports and routes required by your module.

__version__.py

The generated __version__.py file defines the initial version and a human-readable module name:

__version__ = “0.1.0”
__module_name__ = “My Module”

The version provides a starting point for tracking the module’s development. Update it when your module’s version changes.

After the command finishes

Generating the app structure is only the first step. You must configure and implement the module before using it.

  1. Configure the installed app. Add the correct Python app path to INSTALLED_APPS in your project’s settings. If the app is nested inside another package, use the appropriate dotted import path.

Define your models. Add the required model classes in models.py. Then generate and apply migrations:
python manage.py makemigrations my_module

  1. python manage.py migrate
  2. Create views and routes. Implement your views in views.py and add their URL patterns to urls.py.
  3. Register menu entries. Add the appropriate registrations in menu.py so users can navigate to the new module.
  4. Register models for platform features. Configure registration.py for the Horilla features your models should support.
  5. Implement the remaining functionality. Add forms, filters, templates, signal handlers, tests, and other required components.
  6. Restart the development server. This allows Django and Horilla to load the updated app configuration and registrations.

Good to know

  • Static files use a namespaced directory. The generated assets are placed under static/my_module/assets/. Reference them using the appropriate static-file path for your project, such as my_module/assets/js/your-script.js.
  • The command generates a starting structure, not a complete feature. You still need to implement the models, views, routes, menus, and other functionality required by your module.
  • The –project option currently has no effect. Do not rely on it to configure the app or modify project settings.
  • Check the app’s import path. If you use –directory to create a nested app, make sure the generated configuration and INSTALLED_APPS entry match the actual Python package structure.
  • Use a new app directory. Do not target a directory that already contains code you need to keep. If generation fails and the command removes the newly created target directory during cleanup, any files created there during that attempt may be lost.
  • Locale directories do not contain completed translations. You still need to generate, translate, and compile message files as part of the localization process.

The start_horilla_app management command simplifies the initial setup of a new Horilla CRM module by generating a standard app structure, including an AppLauncher configuration, menu and feature-registration files, URL configuration, static asset directories, and locale folders.

Instead of creating these files manually, you can start with a consistent structure and focus on implementing your module’s functionality. Configure the app correctly, add your models and views, register the required features, and connect the module to Horilla’s navigation system to continue development.

Share this article