django-breeze


Namedjango-breeze JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/Louxsdon/django-breeze
SummaryDjango Breeze provides a minimal and simple starting point for building a Django application with Inertia and Vite with minimal or no configuration. Styled with Tailwind CSS.
upload_time2023-04-30 13:40:33
maintainer
docs_urlNone
authorlouxsdon
requires_python>=3.10,<4.0
licenseMIT
keywords react django vue inertia vite
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![django-breeze-logo](https://user-images.githubusercontent.com/60859741/233969758-939d1091-f04c-4625-8e2a-23697bca58d8.jpg)

# Django Breeze

## Introduction

Django Breeze provides a minimal and simple starting point for building a Django application with `Inertia` and `Vite.js` with minimal or no configuration. Styled with Tailwind CSS.

Inertia helps build single-page apps, without building an API. Create modern single-page React, Vue, and Svelte apps using classic server-side routing. Works with any backend. Documentation for Inertia can be found on the [Intertia website](https://inertiajs.com/).

## Setup and Installation

Before installing the packages, ensure you are in your project's virtual environment.

1. Install the django-breeze package.

```bash
pip install django-breeze
```

2. Create a new django project if you haven't created one already.

```bash
django-breeze startproject myproject
```

Add the django_breeze to your `INSTALLED_APPS` in `settings.py`

```python
INSTALLED_APPS = [
  #..............
  'django_breeze',
  #..............
]
```

### Generate Project Files

Generate your frontend project files with django-breeze, use `--typescript` option for usage with TypeScript.

React

```bash
django-breeze create-app react
```

Vue 3

```bash
django-breeze create-app vue3
```

After generating your frontend project files, you should see `src` directory with other relevant files in the root of your django project.

### Install the frontend packages

Run this command to install packages for the frontend.

```bash
npm install

# or

yarn
```

### Start the Servers

Run the following commands to start your development servers.

1. Vite server

```bash
npm run dev
```

2. Django server

```bash
python manage.py runserver
```

Now visit your django host address at e.g <http://127.0.0.1:8000/>

![django-breeze-success-setup screen](https://user-images.githubusercontent.com/60859741/233971714-3729c1d9-6f9e-4a39-ae38-4d76f14419ef.png)

Now you're all set!

## Usage

### Responses

Render Inertia responses is simple, you can either use the provided inertia render function or, for the most common use case, the inertia decorator. The render function accepts four arguments, the first is your request object. The second is the name of the component you want to render from within your pages directory (without extension). The third argument is a dict of `props` that should be provided to your components. The final argument is `template_data`, for any variables you want to provide to your template, but this is much less common.

```python
# views.py

from inertia import render
from .models import Event

def index(request):
  return render(request, 'Event/Index', props={
    'events': Event.objects.all()
  })
```

Or use the simpler decorator for the most common use cases

```python
# views.py

from inertia import inertia
from .models import Event

@inertia('Event/Index')
def index(request):
  return {
    'events': Event.objects.all(),
  }
```

For more information on the usage, refer to [inertia-django Docs.](https://github.com/inertiajs/inertia-django#usage)

## Production

In production, you must do the following:

1. In the `settings.py`

```python
DEBUG = FALSE
```

2. Run below command to build your frontend files

```bash
npm run build
# or
yarn build
```

3. Run below django command to collect static files.

```bash
python -m manage.py collectstatic
```

## Settings

Although, djang breeze comes with minimal or no configuration but here are some of the default settings it comes with out of the box.

### Django Settings

```python
# settings.py

STATIC_ROOT = "static"

 DJANGO_BREEZE = {
        "INERTIA": {
            "LAYOUT": "index.html",
            "SSR_URL": "http://localhost:13714",
            "SSR_ENABLED": False,
        },
        "DJANGO_VITE": {
            "DEV_MODE": True, # vite dev mode, default based on django DEBUG
            "SERVER_PROTOCOL": "http",
            "DEV_SERVER_HOST": "localhost",
            "DEV_SERVER_PORT": 5173,
            "WS_CLIENT_URL": "@vite/client",
            "ASSETS_PATH": "static/dist", # vite build asset path
            "STATIC_URL_PREFIX": "",
        }
 }
```

Settings for [Inertia Django](https://github.com/inertiajs/inertia-django) is under `INERTIA` and [Django Vite](https://github.com/MrBin99/django-vite) is `DJANGO_VITE`. You can find more explaination of the settings on their repos

`Note:` All settings are joined with underscore to match how their developers defined them e.g inertia settings is `INERTIA_LAYOUT` and django vite is `DJANGO_VITE_DEV_MODE` which has been done automatically by django breeze so you just use the `DJANGO_BREEZE` settings format in your `settings.py` file.

## Thank you

A very big thanks to the following people for their work done:

- [Inertia.js Team](https://github.com/inertiajs) for Inertia Django Adaptor.
- [MrBin99](https://github.com/MrBin99) for Django Vite.

## License

Django Breeze is open-sourced software licensed under the [MIT license](LICENSE.md).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Louxsdon/django-breeze",
    "name": "django-breeze",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "react,django,vue,inertia,vite",
    "author": "louxsdon",
    "author_email": "louisayivi.dev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8e/fc/76acec06a711c259af1a313b13cdcfa4a9135a7b5b0f04bffd73237b3ddf/django_breeze-1.0.0.tar.gz",
    "platform": null,
    "description": "![django-breeze-logo](https://user-images.githubusercontent.com/60859741/233969758-939d1091-f04c-4625-8e2a-23697bca58d8.jpg)\n\n# Django Breeze\n\n## Introduction\n\nDjango Breeze provides a minimal and simple starting point for building a Django application with `Inertia` and `Vite.js` with minimal or no configuration. Styled with Tailwind CSS.\n\nInertia helps build single-page apps, without building an API. Create modern single-page React, Vue, and Svelte apps using classic server-side routing. Works with any backend. Documentation for Inertia can be found on the [Intertia website](https://inertiajs.com/).\n\n## Setup and Installation\n\nBefore installing the packages, ensure you are in your project's virtual environment.\n\n1. Install the django-breeze package.\n\n```bash\npip install django-breeze\n```\n\n2. Create a new django project if you haven't created one already.\n\n```bash\ndjango-breeze startproject myproject\n```\n\nAdd the django_breeze to your `INSTALLED_APPS` in `settings.py`\n\n```python\nINSTALLED_APPS = [\n  #..............\n  'django_breeze',\n  #..............\n]\n```\n\n### Generate Project Files\n\nGenerate your frontend project files with django-breeze, use `--typescript` option for usage with TypeScript.\n\nReact\n\n```bash\ndjango-breeze create-app react\n```\n\nVue 3\n\n```bash\ndjango-breeze create-app vue3\n```\n\nAfter generating your frontend project files, you should see `src` directory with other relevant files in the root of your django project.\n\n### Install the frontend packages\n\nRun this command to install packages for the frontend.\n\n```bash\nnpm install\n\n# or\n\nyarn\n```\n\n### Start the Servers\n\nRun the following commands to start your development servers.\n\n1. Vite server\n\n```bash\nnpm run dev\n```\n\n2. Django server\n\n```bash\npython manage.py runserver\n```\n\nNow visit your django host address at e.g <http://127.0.0.1:8000/>\n\n![django-breeze-success-setup screen](https://user-images.githubusercontent.com/60859741/233971714-3729c1d9-6f9e-4a39-ae38-4d76f14419ef.png)\n\nNow you're all set!\n\n## Usage\n\n### Responses\n\nRender Inertia responses is simple, you can either use the provided inertia render function or, for the most common use case, the inertia decorator. The render function accepts four arguments, the first is your request object. The second is the name of the component you want to render from within your pages directory (without extension). The third argument is a dict of `props` that should be provided to your components. The final argument is `template_data`, for any variables you want to provide to your template, but this is much less common.\n\n```python\n# views.py\n\nfrom inertia import render\nfrom .models import Event\n\ndef index(request):\n  return render(request, 'Event/Index', props={\n    'events': Event.objects.all()\n  })\n```\n\nOr use the simpler decorator for the most common use cases\n\n```python\n# views.py\n\nfrom inertia import inertia\nfrom .models import Event\n\n@inertia('Event/Index')\ndef index(request):\n  return {\n    'events': Event.objects.all(),\n  }\n```\n\nFor more information on the usage, refer to [inertia-django Docs.](https://github.com/inertiajs/inertia-django#usage)\n\n## Production\n\nIn production, you must do the following:\n\n1. In the `settings.py`\n\n```python\nDEBUG = FALSE\n```\n\n2. Run below command to build your frontend files\n\n```bash\nnpm run build\n# or\nyarn build\n```\n\n3. Run below django command to collect static files.\n\n```bash\npython -m manage.py collectstatic\n```\n\n## Settings\n\nAlthough, djang breeze comes with minimal or no configuration but here are some of the default settings it comes with out of the box.\n\n### Django Settings\n\n```python\n# settings.py\n\nSTATIC_ROOT = \"static\"\n\n DJANGO_BREEZE = {\n        \"INERTIA\": {\n            \"LAYOUT\": \"index.html\",\n            \"SSR_URL\": \"http://localhost:13714\",\n            \"SSR_ENABLED\": False,\n        },\n        \"DJANGO_VITE\": {\n            \"DEV_MODE\": True, # vite dev mode, default based on django DEBUG\n            \"SERVER_PROTOCOL\": \"http\",\n            \"DEV_SERVER_HOST\": \"localhost\",\n            \"DEV_SERVER_PORT\": 5173,\n            \"WS_CLIENT_URL\": \"@vite/client\",\n            \"ASSETS_PATH\": \"static/dist\", # vite build asset path\n            \"STATIC_URL_PREFIX\": \"\",\n        }\n }\n```\n\nSettings for [Inertia Django](https://github.com/inertiajs/inertia-django) is under `INERTIA` and [Django Vite](https://github.com/MrBin99/django-vite) is `DJANGO_VITE`. You can find more explaination of the settings on their repos\n\n`Note:` All settings are joined with underscore to match how their developers defined them e.g inertia settings is `INERTIA_LAYOUT` and django vite is `DJANGO_VITE_DEV_MODE` which has been done automatically by django breeze so you just use the `DJANGO_BREEZE` settings format in your `settings.py` file.\n\n## Thank you\n\nA very big thanks to the following people for their work done:\n\n- [Inertia.js Team](https://github.com/inertiajs) for Inertia Django Adaptor.\n- [MrBin99](https://github.com/MrBin99) for Django Vite.\n\n## License\n\nDjango Breeze is open-sourced software licensed under the [MIT license](LICENSE.md).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django Breeze provides a minimal and simple starting point for building a Django application with Inertia and Vite with minimal or no configuration. Styled with Tailwind CSS.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/Louxsdon/django-breeze",
        "Repository": "https://github.com/Louxsdon/django-breeze"
    },
    "split_keywords": [
        "react",
        "django",
        "vue",
        "inertia",
        "vite"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d3346d5aaf34101ed6eb492b017e5c2c5ba2994864b113ad846c416baef13a3f",
                "md5": "19a930caa658bfe4a3e1d6a3ef0c5063",
                "sha256": "3f4574273eed612904058127f35a930682db0c18ef514f190d559af0b855deef"
            },
            "downloads": -1,
            "filename": "django_breeze-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "19a930caa658bfe4a3e1d6a3ef0c5063",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 355029,
            "upload_time": "2023-04-30T13:40:30",
            "upload_time_iso_8601": "2023-04-30T13:40:30.946888Z",
            "url": "https://files.pythonhosted.org/packages/d3/34/6d5aaf34101ed6eb492b017e5c2c5ba2994864b113ad846c416baef13a3f/django_breeze-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8efc76acec06a711c259af1a313b13cdcfa4a9135a7b5b0f04bffd73237b3ddf",
                "md5": "7a883d3206359a9b09efef5c71b10b35",
                "sha256": "4bfadc5d5b9a85d9fa8669066ad2da89414055a9ff1866d5d1ac652467adb38d"
            },
            "downloads": -1,
            "filename": "django_breeze-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7a883d3206359a9b09efef5c71b10b35",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 334416,
            "upload_time": "2023-04-30T13:40:33",
            "upload_time_iso_8601": "2023-04-30T13:40:33.593515Z",
            "url": "https://files.pythonhosted.org/packages/8e/fc/76acec06a711c259af1a313b13cdcfa4a9135a7b5b0f04bffd73237b3ddf/django_breeze-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-30 13:40:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Louxsdon",
    "github_project": "django-breeze",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-breeze"
}
        
Elapsed time: 0.07930s