This template provides a streamlined setup for integrating a React + Tailwind app (built with Vite) into a Django project. It's designed to be used as a Django app, offering a modern front-end development experience within a robust Python web framework.
Ensure you have an existing Django project. Your initial file structure should look like this:
/
├── project/
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── manage.py
Clone this template repository:
git clone https://github.com/an4s911/reactapp-django-starter.git yourappname
After cloning, your file structure will update to:
/
├── project/
│ ├── asgi.py
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── manage.py
└── yourappname/
├── src/
│ ├── App.jsx
│ ├── index.css
│ └── main.jsx
├── templates/
│ └── base.html
├── __init__.py
├── apps.py
├── views.py
├── index.html
├── package.json
├── vite.config.js
├── tailwind.config.js
├── eslint.config.js
├── postcss.config.js
├── yarn.lock
└── README.md
Update the app name in yourappname/apps.py
:
from django.apps import AppConfig
# Update the app name
class YourAppNameConfig(AppConfig): # <-- here
default_auto_field = "django.db.models.BigAutoField"
name = "yourappname" # <-- and here
Install dependencies:
cd yourappname
yarn install
Start the Vite build process:
yarn refresh
Note: For development purposes only, you can run yarn dev
to start the Vite development server. This cannot be used alongside Django.
Add the app to your Django project in project/settings.py
:
INSTALLED_APPS = [
# ... other apps
"yourappname",
]
Configure static files in project/settings.py
:
STATICFILES_DIRS = [
BASE_DIR / "yourappname/dist",
]
Update project/urls.py
to include your app's views:
from django.urls import path
from yourappname import views
urlpatterns = [
# ... other urls
path("", views.index, name="index"),
]
Start the Django development server:
python manage.py runserver 0.0.0.0:8000
Visit http://localhost:8000
in your browser to see your app in action!
yourappname/src
directory.yarn refresh
) will automatically rebuild your app.Before deploying to production:
yarn build
to create an optimized production build.DEBUG = False
in your Django settings.yourappname/dist
directory.python manage.py collectstatic
.STATIC_URL
and STATIC_ROOT
setting is correctly configured.Contributions are welcome! Please feel free to submit a Pull Request.