Skip to content

Commit b1e1e24

Browse files
authored
Initial commit
0 parents  commit b1e1e24

24 files changed

+5138
-0
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
frontend/node_modules
2+
frontend/dist
3+
4+
db.sqlite3
5+
6+
# Django #
7+
*.log
8+
*.pot
9+
*.pyc
10+
__pycache__
11+
db.sqlite3
12+
media
13+
14+
# Visual Studio Code #
15+
.vscode
16+
!.vscode/settings.json
17+
!.vscode/tasks.json
18+
!.vscode/launch.json
19+
!.vscode/extensions.json
20+
.history
21+
22+
# Environments
23+
.env
24+
.venv
25+
env/
26+
venv/
27+
ENV/
28+
env.bak/
29+
venv.bak/

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Django, React, Vite & Tailwind CSS Template
2+
3+
This is a starter template for building a full stack Django, React, Vite & Tailwind CSS Template on [Coherence](withcoherence.com).
4+
5+
## How to use
6+
7+
1. Sign up for an account at [app.withcoherence.com](https://app.withcoherence.com/)
8+
2. Once you have created an account, create a new application.
9+
3. On the "App details" page, inside step #2 "Import a repo," click on the "Import feature" link to import a repo into your GitHub account.
10+
4. Copy and paste this repo's URL `https://github.com/coherenceplatform/django-react-tailwind-template` into the "Your old repository’s clone URL" field.
11+
5. Give your new repo a name and then click the "Begin import" button.
12+
6. After the repo has imported, copy and paste the new repo's URL into the "Repo URL" field in Coherence.
13+
7. Follow the remaining onboarding instructions.
14+
15+
Coherence will set up your Cloud IDE, automatic preview environments, CI/CD pipelines, and managed cloud infrastructure.

backend/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3
2+
3+
ENV PYTHONDONTWRITEBYTECODE=1
4+
ENV PYTHONUNBUFFERED=1
5+
6+
WORKDIR /app
7+
COPY requirements.txt .
8+
RUN pip install -r requirements.txt
9+
COPY . .
10+
11+
CMD ["python3", "manage.py", "runserver", "0.0.0.0:$PORT"]

backend/backend/__init__.py

Whitespace-only changes.

backend/backend/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for backend2 project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
15+
16+
application = get_asgi_application()

backend/backend/settings.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
"""
2+
Django settings for backend project.
3+
"""
4+
5+
from pathlib import Path
6+
import dj_database_url
7+
import os
8+
9+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
10+
BASE_DIR = Path(__file__).resolve().parent.parent
11+
12+
13+
SECRET_KEY = os.environ.get("SECRET_KEY", "CHANGE_ME!!!!")
14+
ALLOWED_HOSTS = ["*"]
15+
# SECURITY WARNING: don't run with debug turned on in production!
16+
DEBUG = os.environ.get("COHERENCE_ENVIRONMENT_NAME", "dev") != "production"
17+
18+
19+
# Application definition
20+
21+
INSTALLED_APPS = [
22+
'django.contrib.admin',
23+
'django.contrib.auth',
24+
'django.contrib.contenttypes',
25+
'django.contrib.sessions',
26+
'django.contrib.messages',
27+
]
28+
29+
MIDDLEWARE = [
30+
'django.middleware.security.SecurityMiddleware',
31+
'django.contrib.sessions.middleware.SessionMiddleware',
32+
'django.middleware.common.CommonMiddleware',
33+
'django.middleware.csrf.CsrfViewMiddleware',
34+
'django.contrib.auth.middleware.AuthenticationMiddleware',
35+
'django.contrib.messages.middleware.MessageMiddleware',
36+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
37+
]
38+
39+
ROOT_URLCONF = 'backend.urls'
40+
41+
TEMPLATES = [
42+
{
43+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
44+
'DIRS': [],
45+
'APP_DIRS': True,
46+
'OPTIONS': {
47+
'context_processors': [
48+
'django.template.context_processors.debug',
49+
'django.template.context_processors.request',
50+
'django.contrib.auth.context_processors.auth',
51+
'django.contrib.messages.context_processors.messages',
52+
],
53+
},
54+
},
55+
]
56+
57+
# Database
58+
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
59+
60+
DATABASES = {
61+
'default': {
62+
'ENGINE': 'django.db.backends.sqlite3',
63+
'NAME': BASE_DIR / 'db.sqlite3',
64+
}
65+
}
66+
67+
if "DATABASE_URL" in os.environ:
68+
# Configure Django for DATABASE_URL environment variable.
69+
DATABASES["default"] = dj_database_url.config()
70+
71+
72+
# Password validation
73+
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
74+
75+
AUTH_PASSWORD_VALIDATORS = [
76+
{
77+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
78+
},
79+
{
80+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
81+
},
82+
{
83+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
84+
},
85+
{
86+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
87+
},
88+
]
89+
90+
91+
# Internationalization
92+
# https://docs.djangoproject.com/en/3.2/topics/i18n/
93+
94+
LANGUAGE_CODE = 'en-us'
95+
96+
TIME_ZONE = 'UTC'
97+
98+
USE_I18N = True
99+
100+
USE_L10N = True
101+
102+
USE_TZ = True
103+
104+
# Default primary key field type
105+
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
106+
107+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

backend/backend/urls.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""backend2 URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/4.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path
18+
19+
urlpatterns = [
20+
path('admin/', admin.site.urls),
21+
]

backend/manage.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

backend/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Django==4.1.1
2+
pytz==2022.2.1
3+
uvicorn
4+
dj_database_url
5+
psycopg2

coherence.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
backend:
2+
type: backend
3+
url_path: /api
4+
repo_path: backend
5+
# migration: ["python", "manage.py", "migrate"]
6+
7+
dev: ["python", "manage.py", "runserver", "0.0.0.0:$PORT"]
8+
prod: ["uvicorn", "backend.asgi:application", "--port=$PORT", "--host=0.0.0.0"]
9+
10+
resources:
11+
- name: db1
12+
engine: postgres
13+
version: 13
14+
type: database
15+
16+
frontend:
17+
type: frontend
18+
index_file_name: index.html
19+
url_path: /
20+
repo_path: frontend
21+
assets_path: dist
22+
23+
local_packages: ["node_modules"]
24+
install: ["npm", "install"]
25+
build: ["npm", "run", "build"]
26+
dev: ["npm", "run", "dev"]

0 commit comments

Comments
 (0)