A minimal Django app for navigating through daily task pages, showcasing simple routing and template rendering.
django-admin startproject weekplanner
cd weekplanner
python manage.py startapp tasksINSTALLED_APPS = [
'tasks',
]tasks/templates/tasks/
from django.shortcuts import render
def index(request):
return render(request, 'tasks/index.html')
def monday(request):
return render(request, 'tasks/monday.html')from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('monday/', views.monday, name='monday'),
...add more days here
]from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('tasks/', include('tasks.urls')),
]Django>=3.2,<4 gunicorn
ALLOWED_HOSTS = ['weekplanner-zntz.onrender.com']
python -m venv .venv
.venv\Scripts\activate
(.venv) python manage.py runserver
pip install django -- incase shows module not found
technically it should
weekplanner/static/css/styles.css
STATIC_URL = 'static/'
STATICFILES_DIRS = [
BASE_DIR / "static", # This points to the static directory
]STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / "static"]
STATIC_ROOT = BASE_DIR / "staticfiles"python manage.py collectstatic -- before each deployment it seems
MIDDLEWARE = [
'whitenoise.middleware.WhiteNoiseMiddleware',
# ... the rest
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'pip install whitenoise -- WhiteNoise lets Django serve static files without needing Nginx or some external server.
pip freeze > requirements.txt
Tell your platform how to run your app Put this file in your root directory (no extension), and inside write:
web: gunicorn weekplanner.wsgi:application