Metadata-Version: 2.4
Name: modelw-project-maker
Version: 2026.10.2
Summary: A tool to create Model-W-compliant projects
License: WTFPL
Keywords: model-w,django,nuxt,boilerplate,template
Author: Rémy Sanchez
Author-email: remy.sanchez@hyperthese.net
Requires-Python: >=3.14,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Utilities
Requires-Dist: Unidecode (>=1.4.0,<2.0.0)
Requires-Dist: node-edge (>=1.0.0,<2.0.0)
Requires-Dist: pathspec (>=1.1.1,<2.0.0)
Requires-Dist: rich (>=15.0.0,<16.0.0)
Requires-Dist: ruff (>=0.14)
Requires-Dist: setuptools
Requires-Dist: textual (>=8.2.8,<9.0.0)
Requires-Dist: tomlkit (>=0.15.2,<0.16.0)
Project-URL: Documentation, https://github.com/ModelW/project-maker
Project-URL: Homepage, https://github.com/ModelW/project-maker
Project-URL: Repository, https://github.com/ModelW/project-maker
Description-Content-Type: text/markdown

# Model&nbsp;W Project Maker

This project maker is the simplest way to start a
[Model W](https://model-w.readthedocs.io/en/latest/) project.

The goal is to be extremely simple:

```bash
uvx --from modelw-project-maker --python 3.14 project_maker
```

This opens a wizard in your terminal:

-   On the left, the options: the project's name, its location (with a folder
    picker) and the components to include. The names derived from the
    project's name (Python package, folder) can be overridden, and are checked
    as you type.
-   On the right, a live preview: where the project goes, its names, its URLs,
    what `snow.yml` deploys and the tree of the files that will be generated.

Create the project with <kbd>Ctrl</kbd>+<kbd>G</kbd> (or the button), then
follow the steps of the generation. The default location is `~/dev`, change
it with `--dev-dir` or the `MODEL_W_DEV_DIR` environment variable.

## Prerequisites

In order to execute the script, you need:

-   Python 3.14 (you can use pyenv to load it in your current shell)
-   Poetry (follow the instructions on
    [their website](https://python-poetry.org/docs/#installation))
-   Git (you know where to get it)
-   Git Flow (`apt install git-flow` or `brew install git-flow` depending on
    your OS)
-   Node and PNPM (get it your favorite way)
-   PostgreSQL and Redis (if you enable the API side)

## What to do next

Once the script is done, you'll have a directory with the project's name. You
can then `cd` into it and start working on it.

### Environment setup

You can start by installing the dependencies:

```bash
# If you enabled the API
cd api
poetry install
cd ..

# If you enabled the frontend
cd front
pnpm install
```

If you enabled the API, you then need to create the database:

```bash
sudo -u postgres psql -c "CREATE DATABASE <project_name>"
sudo -u postgres psql -c "CREATE USER <project_name> WITH LOGIN PASSWORD '<project_name>'"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE <project_name> TO <project_name>"
```

Finally, have a look at `api/.env` and/or `front/.env` and make sure that values
there are correct.

For the Django side, until you add more settings by yourself to `settings.py`,
you can use all the settings from the
[Model&nbsp;W Django Preset](https://modelw-django-preset.readthedocs.io/en/latest/).

If you've enabled Wagtail, you need to configure the
[storage environment variables](https://modelw-django-preset.readthedocs.io/en/latest/storage.html),
which should be commented out in your `.env`. You need to check with someone in
charge of the infrastructure to get those values (if it's yourself, you're in
luck).

### Django models customization

Something important in Django is to customize the User model to your needs. Even
if you don't need it right now, you'll eventually be happy that you did it
because you'll _always_ need to add fields to it.

Thus one of the first things you should do is to go check in the `people` app's
models the custom `User` model that is provided by default in this template.
Modify it to your needs.

> **Note** &mdash; If you modify the User model and you are not satisfied with
> the initial migration then you can delete it and create it anew. The only
> thing is that you'll have to manually add `CreateExtension("citext")` on top
> of the operations list in the `0001_initial.py` migration file.

If you've enabled Wagtail, the same applies for the `Image` and `Document`
models present in the `cms` app.

Still in Wagtail, the root page is replaced by a `HomePage` (defined in
`cms/models.py`) in one of the migrations generated by the template. If that's
not okay for you, now is the time to change it. However most likely it's going
to be convenient for you, because otherwise you'll need to do it manually in
Wagtail's admin. The only drawback is that when you'll want to add fields to the
`HomePage` you will have to figure default values.

Once you've adjusted all the models to your needs, feel free to make the
migrations and run them:

```bash
api/pmanage makemigrations
api/pmanage migrate
```

> **Note** &mdash; You'll notice that there is a `pmanage` script in addition of
> the `manage.py` script. It's simply a wrapper to call `manage.py` through the
> Poetry virtual environment.

### SvelteKit/Wagtail integration

If you have chosen a CMS, there will be a SvelteKit/Wagtail integration, using
Wagtail's v2 API.

The `front/src/routes/(site)/(cms)/[...cmsPath=cmsPath]` route is a catch-all
for all the CMS paths. Inside `$lib/components/cms/` you'll find the Svelte
components for the CMS:

-   `pages/` &mdash; One component per Wagtail page type, with the same name.
    It is automatically imported and rendered when landing on a page of that
    type.
-   `blocks/` &mdash; One component per StreamField block, with the same name.
    The `StreamField` component renders them, nothing to register.
-   `snippets/` &mdash; One component per previewable snippet, rendered by the
    snippet preview.

The wizard can also add a demo snippet, to show how snippet previews work.

Have a look at the front's README for the rest (layout, menus, session and
route rules).

## Contributing

### Tests

The test suite generates a project for every combination of options and checks
it:

```bash
make test       # Generates every combination and checks them statically
make test_slow  # Installs, lints, type-checks and builds some of them
```

The slow tests need network access, `pnpm` and `poetry`.

### Formatting

```bash
make format  # Formats the project maker and the template
make lint    # Checks what the CI checks
```

The template itself only needs to be formattable (template directives would
make most linters unhappy). Generated projects, on the other hand, must pass
all their linters: the project maker runs Ruff with auto-fix and Prettier on
them, and the tests check that nothing remains.

### Releasing

If you're developing this package and you want to make a release, you can simply
run:

```bash
make release VERSION=<version>
```

Then you'll still need to push the branches and tags.

