Skip to main content

Opinionated Django frontend scaffolder using ViteJS

Project description

Django Frontend Kit

Python Django Vite

Django Frontend Kit is an opinionated frontend scaffolder for Django, integrating seamlessly with ViteJS. It provides a streamlined setup for modern frontend tooling within your Django projects, enabling efficient development and production workflows.


🚀 Features

  • 📦 Seamless ViteJS Integration – Enables modern frontend tooling in Django.
  • Zero Config Development – Uses Vite’s dev server automatically during development.
  • 🔧 Production-Ready Setup – Manages static assets via Django’s collectstatic mechanism.
  • 🛠 Easy Scaffolding – One command to generate the required frontend structure.

📥 Installation

You can install django-frontend-kit using your preferred package manager:

Using uv

uv add django-frontend-kit

Using Poetry

poetry add django-frontend-kit

Using pip

pip install django-frontend-kit

🔧 Configuration

1️⃣ Add to Installed Apps

In your settings.py, add django-frontend-kit to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "frontend_kit",
    ...
]

2️⃣ Define Frontend Directory

By default, django-frontend-kit looks for a frontend directory specified by DJFK_FRONTEND_DIR. It is recommended to place it in the root of your project:

DJFK_FRONTEND_DIR = BASE_DIR / "frontend"

Templating support

For Django template engine to find the frontend files, add DJFK_FRONTEND_DIR to TEMPLATES DIRS in settings.py:

TEMPLATES = [
    {
        ...
        "DIRS": [
            ...
            DJFK_FRONTEND_DIR
            ...
        ],
        ...
    }
]

3️⃣ Configure Vite Integration

During development, django-frontend-kit will use Vite's dev server. Set the dev server URL:

VITE_DEV_SERVER_URL = "http://localhost:5173/"

To collect staticfiles built by Vite, add the VITE_OUTPUT_DIR to STATICFILES_DIRS in settings.py:

VITE_OUTPUT_DIR = os.environ.get("VITE_OUTPUT_DIR", "./dist")
STATICFILES_DIRS = [VITE_OUTPUT_DIR]

⚡ Quick Start

1️⃣ Frontend Setup

Run the following command to create the required frontend structure:

python manage.py scaffold

This will generate the frontend directory and Vite configuration in BASE_DIR.

2️⃣ Initialize the Frontend Project

Create a package.json file:

npm init -y

Install the necessary dependencies:

npm install vite @iamwaseem99/vite-plugin-django-frontend-kit

Start Development Server

To start the development server, run:

npm run dev 

Build for Production

To generate production-ready frontend assets, run:

npm run build

and run the following command to collect static files:

python manage.py collectstatic  

TODO:

README

  • [] Add philosophy.
  • [] Explain the project structure.
  • [] Add how to add and use layouts, pages, shared files.
  • [] Add how to use third party libraries like tailwind, react, alpine, etc.

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_frontend_kit-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_frontend_kit-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file django_frontend_kit-0.1.0.tar.gz.

File metadata

  • Download URL: django_frontend_kit-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for django_frontend_kit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7fd3becdbf209a096ee9c7d807b82e0f53f46726c2c4389f7579fb0476111908
MD5 6d82e4eaeb3155dcf2894165f55ccd4c
BLAKE2b-256 beb642f80183fbc830a1b868bb5b5e37efec412948556b5b9b078cdfb46dbbac

See more details on using hashes here.

File details

Details for the file django_frontend_kit-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_frontend_kit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd97b40d92dc22c56bf580098cfa1f2cda7ffafa7402dcef57aafb3e5e485f64
MD5 6f993bbb8a121d995b147124d6b82009
BLAKE2b-256 bf7ec299d63afd4dcd824f2c22c7e1ca66b1a0626796b39e65a0a2599f627924

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page