Package: django-breeze
Django BreezeIntroductionDjango Breeze provides a minimal and simple starting point for building a Django application withInertiaandVite.jswith 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 theIntertia website.Setup and InstallationBefore installing the packages, ensure you are in your project's virtual environment.Install the django-breeze package.pipinstalldjango-breezeCreate a new django project if you haven't created one already.django-breezestartprojectmyprojectAdd the django_breeze to yourINSTALLED_APPSinsettings.pyINSTALLED_APPS=[#..............'django_breeze',#..............]Generate Project FilesGenerate your frontend project files with django-breeze, use--typescriptoption for usage with TypeScript.Reactdjango-breezecreate-appreactVue 3django-breezecreate-appvue3After generating your frontend project files, you should seesrcdirectory with other relevant files in the root of your django project.Install the frontend packagesRun this command to install packages for the frontend.npminstall# oryarnStart the ServersRun the following commands to start your development servers.Vite servernpmrundevDjango serverpythonmanage.pyrunserverNow visit your django host address at e.ghttp://127.0.0.1:8000/Now you're all set!UsageResponsesRender 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 ofpropsthat should be provided to your components. The final argument istemplate_data, for any variables you want to provide to your template, but this is much less common.# views.pyfrominertiaimportrenderfrom.modelsimportEventdefindex(request):returnrender(request,'Event/Index',props={'events':Event.objects.all()})Or use the simpler decorator for the most common use cases# views.pyfrominertiaimportinertiafrom.modelsimportEvent@inertia('Event/Index')defindex(request):return{'events':Event.objects.all(),}For more information on the usage, refer toinertia-django Docs.ProductionIn production, you must do the following:In thesettings.pyDEBUG=FALSERun below command to build your frontend filesnpmrunbuild# oryarnbuildRun below django command to collect static files.python-mmanage.pycollectstaticSettingsAlthough, 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# settings.pySTATIC_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 forInertia Djangois underINERTIAandDjango ViteisDJANGO_VITE. You can find more explaination of the settings on their reposNote:All settings are joined with underscore to match how their developers defined them e.g inertia settings isINERTIA_LAYOUTand django vite isDJANGO_VITE_DEV_MODEwhich has been done automatically by django breeze so you just use theDJANGO_BREEZEsettings format in yoursettings.pyfile.Thank youA very big thanks to the following people for their work done:Inertia.js Teamfor Inertia Django Adaptor.MrBin99for Django Vite.LicenseDjango Breeze is open-sourced software licensed under theMIT license.