Skip to main content

Overview

The bootstrap-app command creates a new Django app within an existing SuperApp project by copying a template repository. This command must be run from the superapp/apps directory.

Syntax

django_superapp bootstrap-app [OPTIONS] TARGET_DIRECTORY

Parameters

TARGET_DIRECTORY
string
required
The directory name for the new app. The directory name will also be used as the app name.

Options

--template-repo
string
The GitHub repository URL to use as the app template. Must be a valid GitHub HTTPS or SSH URL.Accepted formats:
Unlike bootstrap-project, this option has no default value. You must specify a template repository.

Directory Requirement

This command must be run from within the superapp/apps directory of your project. If you run it from any other location, you’ll receive an error.

How It Works

  1. Validates that the current directory ends with superapp/apps
  2. Validates the template repository URL format (if provided)
  3. Uses Copier to copy the template repository
  4. Sets the app_name variable to the basename of the target directory
  5. Creates the app structure in the specified location

Examples

Basic Usage

First, navigate to the apps directory:
cd my-project/superapp/apps
Then create a new app:
django_superapp bootstrap-app --template-repo https://github.com/myorg/app-template my-app

Creating Multiple Apps

Create multiple apps in sequence:
cd my-project/superapp/apps
django_superapp bootstrap-app --template-repo https://github.com/myorg/app-template users
django_superapp bootstrap-app --template-repo https://github.com/myorg/app-template products
django_superapp bootstrap-app --template-repo https://github.com/myorg/app-template orders

Using SSH Authentication

For private template repositories:
django_superapp bootstrap-app --template-repo [email protected]:myorg/private-app-template.git my-app

Error Handling

Wrong Directory Error

If you run the command outside of superapp/apps, you’ll see:
Error: You must run this command inside the 'superapp/apps' directory.
Solution: Navigate to the correct directory:
cd path/to/project/superapp/apps

Invalid Repository URL

If the repository URL is invalid:
Error: The repository URL must be a valid GitHub HTTPS or SSH URL.
Solution: Use a properly formatted GitHub URL:

Template Variables

The command automatically passes the following variables to the template:
  • app_name: Extracted from the basename of the target directory

Project Structure

After creating an app, your project structure will look like:
my-project/
└── superapp/
    └── apps/
        ├── my-app/          # Your new app
        │   ├── models.py
        │   ├── views.py
        │   └── ...
        └── another-app/     # Other apps

After Creating an App

Once your app is created:
  1. Register the app in your Django settings:
    INSTALLED_APPS = [
        # ...
        'superapp.apps.my_app',
    ]
    
  2. Create and run migrations if the app includes models:
    python manage.py makemigrations
    python manage.py migrate
    
  3. Add URL patterns if needed:
    # In your main urls.py
    urlpatterns = [
        path('my-app/', include('superapp.apps.my_app.urls')),
    ]
    

bootstrap-project

Create a new SuperApp project first

pull-template

Update your app with template changes

Source Reference

Implementation: main.py:47-66

Build docs developers (and LLMs) love