{"id":31017286,"url":"https://github.com/pmdevita/django-svelte-template","last_synced_at":"2025-10-15T10:04:03.886Z","repository":{"id":158393821,"uuid":"634007672","full_name":"pmdevita/Django-Svelte-Template","owner":"pmdevita","description":"Django + InertiaJS + Svelte + TailwindCSS (with SSR!)","archived":false,"fork":false,"pushed_at":"2025-01-11T15:20:48.000Z","size":29,"stargazers_count":40,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-09T03:35:57.841Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmdevita.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-28T19:50:57.000Z","updated_at":"2025-08-06T15:29:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ac0e18d-9f91-477f-9de2-495128fc0f75","html_url":"https://github.com/pmdevita/Django-Svelte-Template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pmdevita/Django-Svelte-Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmdevita%2FDjango-Svelte-Template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmdevita%2FDjango-Svelte-Template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmdevita%2FDjango-Svelte-Template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmdevita%2FDjango-Svelte-Template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmdevita","download_url":"https://codeload.github.com/pmdevita/Django-Svelte-Template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmdevita%2FDjango-Svelte-Template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274935967,"owners_count":25376836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-13T07:53:54.233Z","updated_at":"2025-10-15T10:04:03.881Z","avatar_url":"https://github.com/pmdevita.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Svelte Template\n\nA template for Django that uses InertiaJS, Svelte, and TailwindCSS. Preconfigured for HMR and SSR.\n\nThe master branch contains the template for use in the instructions, \nand a runnable demo is in the testing branch.\n\n# What is in this template?\n\nIf you're particular about how the template sets things up, you can see the full comparison \n[here](https://github.com/pmdevita/Django-Svelte-Template/compare/django-svelte-base...testing).\n\nThis template builds off of these two templates\n\n- Django 5.2+ default project (backwards compatible to 4)\n- Svelte 5 front end created from `npm create vite@latest`\n\n\u003cdetails\u003e\n\u003csummary\u003eThe following changes have then been made\u003c/summary\u003e\n\n- Django\n    - settings.py\n      - Added `django-vite`, `inertia-django`, `django-js-routes`, and example_app to apps\n      - Added InertiaMiddleware\n      - Added configuration for the template folder\n      - Set the static root directory\n      - Added `web/dist` as a staticfile dir\n      - Configuration for Vite\n      - Configuration for Inertia\n      - Configuration for JS Routes\n    - urls.py\n      - Added example_app urls\n      - Added static asset urls\n    - templates\n      - Added base.html template, with Inertia and Vite set up\n    - example_app\n      - Added an example app to demonstrate Inertia\n- Vite/Front end\n  - Removed default example files from the template\n  - Added `pages` directory to `src` with `Example.svelte`\n  - Setup `main.js` following InertiaJS Svelte docs\n    - Added support for loading a page layout as per the [Inertia docs](https://inertiajs.com/pages)\n  - Setup `ssr.js` following InertiaJS Svelte docs\n    - Added support for loading a page layout as per the [Inertia docs](https://inertiajs.com/pages)\n  - Added default TailwindCSS config\n  - Added default TailwindCSS-recommended PostCSS config\n  - Configured Vite to build with HMR, proper CORS, and correct public path, \nwith options left in to enable SSR\n\u003c/details\u003e\n\n# Usage\n\n## Prerequisites\n\n- Python 3.8+\n- NodeJS 16+\n\n## Instructions\n\n0. Setup a virtual environment/Poetry/whatever and install `django`, `inertia-django`, \n`django-vite`, and `django-js-routes`.\n1. Run \n```\ndjango-admin startproject --template https://github.com/pmdevita/django-svelte-template/archive/master.zip my_django_project .\n```\n2. CD into `web` and run `npm i`\n\n3. Run both Django and Vite (`python manage.py runserver` and `npm run dev`) and visit Django's URL http://127.0.0.1:8000\n\n## Optional: Enable SSR\n\nSSR support is still unpolished in inertia-django, but it is possible to get running. You technically *can* \nuse SSR and HMR together, but you'll have to rebuild the SSR server on every change. Because of this, \nyou might just want to use static builds of your site (`npm run build`).\n\nFirst, we need to build the SSR server application by running `npm run build-ssr`. You can find some \nmore info about Vite SSR [here](https://vitejs.dev/guide/ssr.html). The port can be changed\nin `web/src/ssr.js`.\n\n1. In `web/vite.config.js`, set `hydratable` to `true`.\n2. In `your_django_project/settings.py`, set `INERTIA_SSR_ENABLED` to True (and if you are just using\nstatic builds, set `DJANGO_VITE_DEV_MODE` to False)\n3. After building the SSR server, run it (ex. with current directory in `web`, `node dist-ssr/ssr.js`)\n4. Run Django\n\n\n# Future/Additional\n\nA few things might be nice to have housed in this project as well.\n\n- Typescript version (made with `npm create vite@latest` with Svelte TypeScript option)\n- Templates for Vue and React\n\n# Contributing\n\nSince we try to maintain both a working example and a template on the same \ngit history, there's a bit of a process to updating this. Updates fall into \nthree categories\n\n1. Stock Django and Svelte/Vite config\n2. Django/Svelte example project\n3. Django template changes\n\nEach one belongs to a separate branch, which are chained by rebasing from\n`django-svelte-base` -\u003e `testing` -\u003e `master`\n\nYou can look at the current vanilla Django templates here https://github.com/django/django/tree/main/django/conf/project_template\n\nSvelte install is generated with \n\n```shell\nnpm create vite@latest\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmdevita%2Fdjango-svelte-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmdevita%2Fdjango-svelte-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmdevita%2Fdjango-svelte-template/lists"}