mirror of
https://github.com/thecyberlearn/modern-django-starter.git
synced 2026-08-18 17:52:54 +00:00
This commit represents a complete migration from Bootstrap to Tailwind CSS with modern, professional UI design: ## Major Changes: - **Tailwind CSS Integration**: Added django-tailwind package with Node.js 18.x support - **UI Redesign**: Complete template migration to modern black/white theme - **Responsive Design**: Mobile-first approach with improved navigation - **Database Enhancement**: Added DATABASE_URL support for external services (Neon, Supabase, Railway, etc.) - **Documentation**: Updated README.md and DEPLOYMENT.md with Tailwind and database guidance ## Technical Improvements: - Hot-reloading during development with django-browser-reload - Production-optimized CSS builds with purging and minification - Professional card layouts and components - Sticky footer implementation - Mobile-responsive navigation with hamburger menu - Modern alert/message styling ## Files Modified: - All HTML templates converted to Tailwind utility classes - Added theme app with Tailwind configuration - Updated Docker configuration for Node.js support - Enhanced settings for third-party database services - Comprehensive documentation updates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
187 lines
5.3 KiB
Python
187 lines
5.3 KiB
Python
"""
|
|
Base settings for Django project.
|
|
"""
|
|
import os
|
|
from pathlib import Path
|
|
from decouple import config
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
|
|
|
SECRET_KEY = config('SECRET_KEY', default='django-insecure-change-this-in-production')
|
|
|
|
DEBUG = config('DEBUG', default=False, cast=bool)
|
|
|
|
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost,127.0.0.1', cast=lambda v: [s.strip() for s in v.split(',')])
|
|
|
|
DJANGO_APPS = [
|
|
'django.contrib.admin',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
'django.contrib.staticfiles',
|
|
'django.contrib.sites',
|
|
]
|
|
|
|
THIRD_PARTY_APPS = [
|
|
'allauth',
|
|
'allauth.account',
|
|
'allauth.socialaccount',
|
|
'allauth.socialaccount.providers.google',
|
|
'whitenoise.runserver_nostatic',
|
|
'tailwind',
|
|
'django_browser_reload',
|
|
]
|
|
|
|
LOCAL_APPS = [
|
|
'apps.accounts',
|
|
'apps.core',
|
|
'theme',
|
|
]
|
|
|
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
|
|
|
MIDDLEWARE = [
|
|
'django.middleware.security.SecurityMiddleware',
|
|
'whitenoise.middleware.WhiteNoiseMiddleware',
|
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
'django.middleware.common.CommonMiddleware',
|
|
'django.middleware.csrf.CsrfViewMiddleware',
|
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
'allauth.account.middleware.AccountMiddleware',
|
|
'django.contrib.messages.middleware.MessageMiddleware',
|
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
]
|
|
|
|
ROOT_URLCONF = 'django_project.urls'
|
|
|
|
TEMPLATES = [
|
|
{
|
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
'DIRS': [BASE_DIR / 'templates'],
|
|
'APP_DIRS': True,
|
|
'OPTIONS': {
|
|
'context_processors': [
|
|
'django.template.context_processors.debug',
|
|
'django.template.context_processors.request',
|
|
'django.contrib.auth.context_processors.auth',
|
|
'django.contrib.messages.context_processors.messages',
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = 'django_project.wsgi.application'
|
|
|
|
import dj_database_url
|
|
|
|
# Database configuration with support for DATABASE_URL
|
|
DATABASE_URL = config('DATABASE_URL', default=None)
|
|
|
|
if DATABASE_URL:
|
|
# Use DATABASE_URL if provided (common for external services like Neon, Heroku, etc.)
|
|
DATABASES = {
|
|
'default': dj_database_url.config(
|
|
default=DATABASE_URL,
|
|
conn_max_age=600,
|
|
conn_health_checks=True,
|
|
)
|
|
}
|
|
else:
|
|
# Use individual environment variables (for Docker Compose and local development)
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': config('DB_NAME', default='django_db'),
|
|
'USER': config('DB_USER', default='django_user'),
|
|
'PASSWORD': config('DB_PASSWORD', default='django_password'),
|
|
'HOST': config('DB_HOST', default='localhost'),
|
|
'PORT': config('DB_PORT', default='5432'),
|
|
'OPTIONS': {
|
|
'sslmode': config('DB_SSLMODE', default='prefer'),
|
|
},
|
|
}
|
|
}
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
},
|
|
{
|
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
},
|
|
]
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
TIME_ZONE = 'UTC'
|
|
USE_I18N = True
|
|
USE_TZ = True
|
|
|
|
STATIC_URL = '/static/'
|
|
STATIC_ROOT = BASE_DIR / 'staticfiles'
|
|
STATICFILES_DIRS = [BASE_DIR / 'static']
|
|
|
|
MEDIA_URL = '/media/'
|
|
MEDIA_ROOT = BASE_DIR / 'media'
|
|
|
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
|
|
AUTH_USER_MODEL = 'accounts.User'
|
|
|
|
SITE_ID = 1
|
|
|
|
AUTHENTICATION_BACKENDS = [
|
|
'django.contrib.auth.backends.ModelBackend',
|
|
'allauth.account.auth_backends.AuthenticationBackend',
|
|
]
|
|
|
|
ACCOUNT_AUTHENTICATION_METHOD = 'email'
|
|
ACCOUNT_EMAIL_REQUIRED = True
|
|
ACCOUNT_USERNAME_REQUIRED = False
|
|
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
|
ACCOUNT_CONFIRM_EMAIL_ON_GET = True
|
|
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True
|
|
ACCOUNT_LOGOUT_ON_GET = True
|
|
ACCOUNT_SESSION_REMEMBER = True
|
|
ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = True
|
|
ACCOUNT_LOGIN_ATTEMPTS_LIMIT = 5
|
|
ACCOUNT_LOGIN_ATTEMPTS_TIMEOUT = 300
|
|
|
|
LOGIN_URL = '/accounts/login/'
|
|
LOGIN_REDIRECT_URL = '/'
|
|
LOGOUT_REDIRECT_URL = '/'
|
|
|
|
EMAIL_BACKEND = config('EMAIL_BACKEND', default='django.core.mail.backends.console.EmailBackend')
|
|
EMAIL_HOST = config('EMAIL_HOST', default='localhost')
|
|
EMAIL_PORT = config('EMAIL_PORT', default=587, cast=int)
|
|
EMAIL_USE_TLS = config('EMAIL_USE_TLS', default=True, cast=bool)
|
|
EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='')
|
|
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default='')
|
|
DEFAULT_FROM_EMAIL = config('DEFAULT_FROM_EMAIL', default='noreply@example.com')
|
|
|
|
SOCIALACCOUNT_PROVIDERS = {
|
|
'google': {
|
|
'SCOPE': [
|
|
'profile',
|
|
'email',
|
|
],
|
|
'AUTH_PARAMS': {
|
|
'access_type': 'online',
|
|
},
|
|
'OAUTH_PKCE_ENABLED': True,
|
|
}
|
|
}
|
|
|
|
SOCIALACCOUNT_LOGIN_ON_GET = True
|
|
|
|
# Tailwind CSS Configuration
|
|
TAILWIND_APP_NAME = 'theme'
|
|
|
|
# Production static files configuration
|
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' |