Skip to content

Instantly share code, notes, and snippets.

View jcjudkins's full-sized avatar

Jason Judkins jcjudkins

View GitHub Profile
@jcjudkins
jcjudkins / uptimerobot_integration_django.py
Created December 12, 2025 20:40
UptimeRobot Integration for Django
`"""`
`UptimeRobot Integration for Django`
`===================================`
`This gist contains code snippets for integrating UptimeRobot`
`with your Django application, including:`
@jcjudkins
jcjudkins / google_analytics_integration.py
Created December 12, 2025 20:38
Google Analytics 4 Integration for Django
`"""`
`Google Analytics 4 Integration for Django`
`==========================================`
`Complete code snippets for integrating Google Analytics 4 (GA4)`
`with your Django application, including:`
@jcjudkins
jcjudkins / django-sentry-setup.py
Created December 12, 2025 20:32
Django Sentry Setup - Quick Integration
"""
Django Sentry Setup - Quick Integration
========================================
Drop this into your Django settings.py for instant Sentry error tracking.
Only activates in production (DEBUG=False).
Installation:
pip install sentry-sdk python-decouple
@jcjudkins
jcjudkins / django-production-security-settings.py
Created December 12, 2025 20:30
Django Production Security Settings
"""
Django Production Security Settings
====================================
Complete security configuration for production Django applications.
Environment-aware: only enforces in production (DEBUG=False).
Add to your settings.py after core settings.
"""
@jcjudkins
jcjudkins / django-env-configuration-template.py
Created December 12, 2025 20:27
Django Environment Configuration Template
"""
Django Environment Configuration Template
==========================================
Complete example of environment-based Django settings using python-decouple.
Installation:
pip install python-decouple
Files needed:
@jcjudkins
jcjudkins / django-dynamic-robots-txt.py
Created December 12, 2025 20:25
Dynamic robots.txt for Django
"""
Dynamic robots.txt for Django
==============================
A simple Django view that generates robots.txt dynamically.
Automatically includes your sitemap URL.
Add to urls.py:
from .views import robots_txt
urlpatterns = [
@jcjudkins
jcjudkins / django-complete-seo-sitemaps.py
Created December 12, 2025 20:24
Complete Django SEO Sitemap Configuration
"""
Complete Django SEO Sitemap Configuration
==========================================
Comprehensive sitemap setup for Django with multiple content types.
Installation:
Add to INSTALLED_APPS:
'django.contrib.sites',
'django.contrib.sitemaps',
@jcjudkins
jcjudkins / django-production-settings.py
Created December 10, 2025 05:28
Django production settings template with security best practices, logging, caching, and environment variables
# Django Production Settings Template
# Best practices for production Django configuration
from pathlib import Path
from decouple import config, Csv
# Build paths
BASE_DIR = Path(__file__).resolve().parent.parent
# SECURITY WARNING: keep the secret key used in production secret!
@jcjudkins
jcjudkins / django-production-deployment-checklist.md
Created December 10, 2025 05:26
Complete checklist for deploying Django to production on DigitalOcean - covers everything from server setup to monitoring

Django Production Deployment Checklist

Complete checklist for deploying Django applications to production on DigitalOcean or similar VPS.

Pre-Deployment

Local Preparation

  • Code is committed to Git
  • All tests passing
  • Requirements.txt is up to date (pip freeze > requirements.txt)
@jcjudkins
jcjudkins / gunicorn-django.service
Created December 10, 2025 05:23
Systemd service file for running Django with Gunicorn - production-ready with logging and auto-restart
# Gunicorn Systemd Service for Django
# Save to: /etc/systemd/system/your-site.service
# Enable with: sudo systemctl enable your-site && sudo systemctl start your-site
[Unit]
Description=Gunicorn daemon for Django Site
After=network.target
[Service]
# User and group to run as