modelw-project-maker


Namemodelw-project-maker JSON
Version 2024.4.0 PyPI version JSON
download
home_pagehttps://github.com/ModelW/project-maker
SummaryA tool to create Model-W-compliant projects
upload_time2024-04-12 13:21:08
maintainerNone
docs_urlNone
authorRémy Sanchez
requires_python<4.0,>=3.11
licenseWTFPL
keywords model-w django nuxt boilerplate template
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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
curl -s https://pypi.run/modelw-project-maker/model_w.project_maker | python3.11
```

This will ask you a few questions and create the project's directory for you.

## Prerequisites

In order to execute the script, you need:

-   Python 3.11 (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 NPM (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
npm 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.

### Nuxt/Wagtail integration

If you have both a front-end and a back-end, you'll have a Nuxt/Wagtail
integration automatically enabled.

All depends on two things:

-   The `*.vue` catchall page in Nuxt. It will catch all requests to the
    front-end and will forward them to Wagtail if they don't match any known
    route. Then it will download the code of those pages (or forward the
    errors/redirections) and render it using...
-   The `ServerTemplatedComponent`. See the inline documentation. It will
    basically allow you to have Vue components getting their template from
    Django-generated HTML. This allows to easily have Django send generated HTML
    and to inject some dynamism in required places in each component.

In case you find the `ServerTemplatedComponent` thing too brittle (it is a bit)
you can decide to keep the same logic but instead of calling HTML pages you can
get content from the API. The default is to use this mechanism because it's
easier to generate from Django, especially if you want to generate image
thumbnails. But well, it's your project, you can do whatever you want.

The default configuration, which depends a lot on the proxy configuration in
`nuxt.config.js`, works seamlessly with Wagtail. As long as you access the
Wagtail URLs through the front-end, the proxy will be invoked when necessary and
JS code will be run otherwise. The live previews work perfectly well and it's up
to you to keep it working.

## Contributing

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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ModelW/project-maker",
    "name": "modelw-project-maker",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": "model-w, django, nuxt, boilerplate, template",
    "author": "R\u00e9my Sanchez",
    "author_email": "remy.sanchez@hyperthese.net",
    "download_url": "https://files.pythonhosted.org/packages/59/ce/140fabf20dad0995f7f3c471910a2bffb56f9d5318e3ac9c17f47236eff7/modelw_project_maker-2024.4.0.tar.gz",
    "platform": null,
    "description": "# Model&nbsp;W Project Maker\n\nThis project maker is the simplest way to start a\n[Model W](https://model-w.readthedocs.io/en/latest/) project.\n\nThe goal is to be extremely simple:\n\n```bash\ncurl -s https://pypi.run/modelw-project-maker/model_w.project_maker | python3.11\n```\n\nThis will ask you a few questions and create the project's directory for you.\n\n## Prerequisites\n\nIn order to execute the script, you need:\n\n-   Python 3.11 (you can use pyenv to load it in your current shell)\n-   Poetry (follow the instructions on\n    [their website](https://python-poetry.org/docs/#installation))\n-   Git (you know where to get it)\n-   Git Flow (`apt install git-flow` or `brew install git-flow` depending on\n    your OS)\n-   Node and NPM (get it your favorite way)\n-   PostgreSQL and Redis (if you enable the API side)\n\n## What to do next\n\nOnce the script is done, you'll have a directory with the project's name. You\ncan then `cd` into it and start working on it.\n\n### Environment setup\n\nYou can start by installing the dependencies:\n\n```bash\n# If you enabled the API\ncd api\npoetry install\ncd ..\n\n# If you enabled the frontend\ncd front\nnpm install\n```\n\nIf you enabled the API, you then need to create the database:\n\n```bash\nsudo -u postgres psql -c \"CREATE DATABASE <project_name>\"\nsudo -u postgres psql -c \"CREATE USER <project_name> WITH LOGIN PASSWORD '<project_name>'\"\nsudo -u postgres psql -c \"GRANT ALL PRIVILEGES ON DATABASE <project_name> TO <project_name>\"\n```\n\nFinally, have a look at `api/.env` and/or `front/.env` and make sure that values\nthere are correct.\n\nFor the Django side, until you add more settings by yourself to `settings.py`,\nyou can use all the settings from the\n[Model&nbsp;W Django Preset](https://modelw-django-preset.readthedocs.io/en/latest/).\n\nIf you've enabled Wagtail, you need to configure the\n[storage environment variables](https://modelw-django-preset.readthedocs.io/en/latest/storage.html),\nwhich should be commented out in your `.env`. You need to check with someone in\ncharge of the infrastructure to get those values (if it's yourself, you're in\nluck).\n\n### Django models customization\n\nSomething important in Django is to customize the User model to your needs. Even\nif you don't need it right now, you'll eventually be happy that you did it\nbecause you'll _always_ need to add fields to it.\n\nThus one of the first things you should do is to go check in the `people` app's\nmodels the custom `User` model that is provided by default in this template.\nModify it to your needs.\n\n> **Note** &mdash; If you modify the User model and you are not satisfied with\n> the initial migration then you can delete it and create it anew. The only\n> thing is that you'll have to manually add `CreateExtension(\"citext\")` on top\n> of the operations list in the `0001_initial.py` migration file.\n\nIf you've enabled Wagtail, the same applies for the `Image` and `Document`\nmodels present in the `cms` app.\n\nStill in Wagtail, the root page is replaced by a `HomePage` (defined in\n`cms/models.py`) in one of the migrations generated by the template. If that's\nnot okay for you, now is the time to change it. However most likely it's going\nto be convenient for you, because otherwise you'll need to do it manually in\nWagtail's admin. The only drawback is that when you'll want to add fields to the\n`HomePage` you will have to figure default values.\n\nOnce you've adjusted all the models to your needs, feel free to make the\nmigrations and run them:\n\n```bash\napi/pmanage makemigrations\napi/pmanage migrate\n```\n\n> **Note** &mdash; You'll notice that there is a `pmanage` script in addition of\n> the `manage.py` script. It's simply a wrapper to call `manage.py` through the\n> Poetry virtual environment.\n\n### Nuxt/Wagtail integration\n\nIf you have both a front-end and a back-end, you'll have a Nuxt/Wagtail\nintegration automatically enabled.\n\nAll depends on two things:\n\n-   The `*.vue` catchall page in Nuxt. It will catch all requests to the\n    front-end and will forward them to Wagtail if they don't match any known\n    route. Then it will download the code of those pages (or forward the\n    errors/redirections) and render it using...\n-   The `ServerTemplatedComponent`. See the inline documentation. It will\n    basically allow you to have Vue components getting their template from\n    Django-generated HTML. This allows to easily have Django send generated HTML\n    and to inject some dynamism in required places in each component.\n\nIn case you find the `ServerTemplatedComponent` thing too brittle (it is a bit)\nyou can decide to keep the same logic but instead of calling HTML pages you can\nget content from the API. The default is to use this mechanism because it's\neasier to generate from Django, especially if you want to generate image\nthumbnails. But well, it's your project, you can do whatever you want.\n\nThe default configuration, which depends a lot on the proxy configuration in\n`nuxt.config.js`, works seamlessly with Wagtail. As long as you access the\nWagtail URLs through the front-end, the proxy will be invoked when necessary and\nJS code will be run otherwise. The live previews work perfectly well and it's up\nto you to keep it working.\n\n## Contributing\n\nIf you're developing this package and you want to make a release, you can simply\nrun:\n\n```bash\nmake release VERSION=<version>\n```\n\nThen you'll still need to push the branches and tags.\n",
    "bugtrack_url": null,
    "license": "WTFPL",
    "summary": "A tool to create Model-W-compliant projects",
    "version": "2024.4.0",
    "project_urls": {
        "Documentation": "https://github.com/ModelW/project-maker",
        "Homepage": "https://github.com/ModelW/project-maker",
        "Repository": "https://github.com/ModelW/project-maker"
    },
    "split_keywords": [
        "model-w",
        " django",
        " nuxt",
        " boilerplate",
        " template"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "72ed4322c7540ce775a9d3a33206a09df2b40ea2c3e69d1f6bc994bc18092bd0",
                "md5": "9a1c10aabf76ba7d6ba95ba831ddb4a2",
                "sha256": "fa55e354067511dc1cb57ebae0a6ea225b738b717608f9dd9be9cc589ef8e00e"
            },
            "downloads": -1,
            "filename": "modelw_project_maker-2024.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9a1c10aabf76ba7d6ba95ba831ddb4a2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 98072,
            "upload_time": "2024-04-12T13:21:06",
            "upload_time_iso_8601": "2024-04-12T13:21:06.783415Z",
            "url": "https://files.pythonhosted.org/packages/72/ed/4322c7540ce775a9d3a33206a09df2b40ea2c3e69d1f6bc994bc18092bd0/modelw_project_maker-2024.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "59ce140fabf20dad0995f7f3c471910a2bffb56f9d5318e3ac9c17f47236eff7",
                "md5": "538ccc731cdd6756c4f1ad57f6650291",
                "sha256": "bc145a2015348fbc9e4bb323adb341d0466af00592f524faeb333d029cfccdca"
            },
            "downloads": -1,
            "filename": "modelw_project_maker-2024.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "538ccc731cdd6756c4f1ad57f6650291",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 65548,
            "upload_time": "2024-04-12T13:21:08",
            "upload_time_iso_8601": "2024-04-12T13:21:08.705045Z",
            "url": "https://files.pythonhosted.org/packages/59/ce/140fabf20dad0995f7f3c471910a2bffb56f9d5318e3ac9c17f47236eff7/modelw_project_maker-2024.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-12 13:21:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ModelW",
    "github_project": "project-maker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "modelw-project-maker"
}
        
Elapsed time: 0.23109s