django-setup
Skill2 starsChanged 13 months agoApache-2.0View on GitHub
Initialize Django projects for HTTPS development with virtual environments and mkcert SSL certificates
- Installs packages
In this repository5 other files it gives its agents.
- apply-shadcnSkill
- django-allauthSkill
- react-allauthSkill
- react-setupSkill
- tailwind-setupSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Create a health API
- Very specific: line 20
Add import and URL routes to urls.py
- Distinctive: line 65
If you have any Python 3.8 - 3.13, use the highest version
- Distinctive: line 66
If no compatible Python found, install Python 3.13
- Distinctive: line 171
Follow the instructions for your operating system:
- Very specific: line 222
Add FRONTEND_URL, ALLOWED_HOSTS, CORS_ALLOWED_ORIGINS AND CSRF_TRUSTED_ORIGINS
- Distinctive: line 324
Default tables for auth, admin, sessions
- Distinctive: line 402
Avoid duplicates: - only add entries that don't already exist (case-insensitive comparison)
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Overview
This skill sets up Django for HTTPS development with virtual environments and local SSL certificates.
Artifacts Builder
To set up Django for HTTPS development with virtual environments and local SSL certificates, follow these steps:
- Verify/Install Python
- Create Virtual Environment
- Install Django and Dependencies
- Create Django Project
- Set Up HTTPS
- Configure settings.py
- Create a health API
- Add import and URL routes to urls.py
- Apply Initial Migrations
- Test HTTPS Server
- Create .gitignore
Step 1: Verify/Install Python
Check for Python 3.8 - 3.13
Check all available Python versions:
Detect the operating system by running uname -s 2>/dev/null || echo %OS% 2>/dev/null || ver
Execute the platform-specific command based on the detected system.
# macOS/Linux
for v in 3.8 3.9 3.10 3.11 3.12 3.13; do
if command -v python$v >/dev/null 2>&1; then
echo "✅ Python $v found: $(python$v --version)"
else
echo "❌ Python $v not found"
fi
done# Windows
$versions = 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
foreach ($v in $versions) {
try {
$output = py -$v --version 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Python $v found: $output"
} else {
Write-Host "❌ Python $v not found"
}
} catch {
Write-Host "❌ Python $v not found"
}
}Strategy:
- If you have any Python 3.8 - 3.13, use the highest version
- If no compatible Python found, install Python 3.13
Install Python 3.13 (if needed)
No compatible Python? See platform-specific installation:
- macOS → platform-install/macos.md
- Ubuntu/Debian → platform-install/linux-ubuntu.md
- Fedora/RHEL → platform-install/linux-fedora.md
- Windows → platform-install/windows.md
Verify installation:
python3.13 --version # or python3.12, python3.11, etc.
which python3.13 # macOS/Linux
where python # WindowsStep 2: Create Virtual Environment
Create venv with your Python version:
# Use highest available version
python3.13 -m venv venv # macOS/Linux
py -3.13 -m venv venv # Windows
# Or use default python3
python3 -m venv venvVerify creation:
ls venv/bin/activate # macOS/Linux - should exist
dir venv\Scripts\activate # Windows - should existErrors? See troubleshooting/venv-issues.md
Step 3: Install Django and Dependencies
Activate virtual environment and upgrade pip:
# macOS/Linux
source venv/bin/activate
pip install --upgrade pip
# Windows (PowerShell)
venv\Scripts\Activate.ps1
pip install --upgrade pip
# Windows (CMD)
venv\Scripts\activate.bat
pip install --upgrade pipInstall core dependencies:
pip install Django python-dotenv djangorestframeworkWhat's installed:
- Django - Web framework
- python-dotenv - Environment variable management (for secrets)
- djangorestframework - REST API toolkit (optional but recommended)
Update requirements.txt:
pip freeze > requirements.txtInstallation issues? See troubleshooting/pip-problems.md
Step 4: Create Django Project
Create project in current directory (flat structure):
django-admin startproject backend .Important: The . creates the project in your current directory, not a subdirectory.
Verify creation:
ls manage.py # Should exist
ls backend/settings.py # Should existStep 5: Set Up HTTPS with mkcert
Detect Operating System
Detect the operating system if you have not done it yet by running:
uname -s 2>/dev/null || echo %OS% 2>/dev/null || verPlatform-Specific Instructions
Follow the instructions for your operating system:
- macOS → platform-https/mkcert-https-setup-macos.md
- Ubuntu/Debian (Linux) → platform-https/mkcert-https-setup-linux.md
- Windows → platform-https/mkcert-https-setup-windows.md
What these guides cover:
- Installing mkcert
- Installing local certificate authority
- Creating SSL certificates directory
- Installing Uvicorn (ASGI server with SSL support)
- Updating requirements.txt
- Creating platform-specific run script (run.sh or run.bat)
Note: Replace backend with your project name if different in the run scripts.
Create VS Code launch configuration:**
For debugging in VS Code, create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Django HTTPS (Uvicorn)",
"type": "debugpy",
"request": "launch",
"module": "uvicorn",
"args": [
"backend.asgi:application",
"--host", "0.0.0.0",
"--port", "8000",
"--ssl-keyfile", "./certs/localhost+2-key.pem",
"--ssl-certfile", "./certs/localhost+2.pem",
"--reload"
],
"django": true,
"justMyCode": true,
"python": "${workspaceFolder}/venv/bin/python"
}
]
}Step 6: Configure settings.py
Find the settings file using Glob tool with pattern "**/*settings.py"
Editing steps for settings.py:
- Add FRONTEND_URL, ALLOWED_HOSTS, CORS_ALLOWED_ORIGINS AND CSRF_TRUSTED_ORIGINS
- Update INSTALLED_APPS
- Update MIDDLEWARE
Add FRONTEND_URL, ALLOWED_HOSTS, CORS_ALLOWED_ORIGINS AND CSRF_TRUSTED_ORIGINS
Find the line ALLOWED_HOSTS = [] in settings.py and replace that single line with:
FRONTEND_URL = 'https://localhost:5173'
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOWED_ORIGINS = [
FRONTEND_URL,
]
CSRF_TRUSTED_ORIGINS = [
FRONTEND_URL,
]Update INSTALLED_APPS
Find the INSTALLED_APPS list and append the following to the end of the list:
# Cross-Origin Resource Sharing
'corsheaders',
# REST API support
'rest_framework',Update MIDDLEWARE
Find the MIDDLEWARE list. After 'django.contrib.sessions.middleware.SessionMiddleware',, add:
'corsheaders.middleware.CorsMiddleware',Critical:
CorsMiddlewaremust come AFTERSessionMiddlewareand BEFORECommonMiddleware
Expected result:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware', # ← Add here
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]Step 7: Create a health API
Create backend/views.py (next to settings.py/urls.py):
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.middleware.csrf import get_token
def api_health(request):
return JsonResponse({
"status": "ok",
"message": "Django is alive and speaking HTTPS",
})
@csrf_exempt
def csrf_token_view(request):
# This forces Django to generate/set the csrftoken cookie
token = get_token(request)
return JsonResponse({"csrftoken": token})Step 8: Add import and URL routes to urls.py
first add from .views import api_health, csrf_token_view to imports and then add these endpoints to urls.py:
path('api/health/', api_health),
path('api/csrf/', csrf_token_view),Step 9: Apply Initial Migrations
Run database migrations:
python manage.py migrateCreates:
db.sqlite3database file- Default tables for auth, admin, sessions
Step 10: Test HTTPS Server
Start the HTTPS server:
macOS/Linux:
./run.shWindows:
run.batExpected output:
INFO: Started server process [12345]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on https://127.0.0.1:8000 (Press CTRL+C to quit)Open browser and visit:
https://localhost:8000Expected:
- ✅ Django welcome page (rocket ship)
- ✅ No certificate warnings (padlock icon shows secure)
- ✅ URL shows
https://nothttp://
If you see certificate warnings: mkcert CA not properly installed. Run mkcert -install again and restart browser.
Stop server: Press Ctrl+C
Issues? See mkcert-https-setup troubleshooting
Step 11: Create .gitignore
Strategy: Check for existing .gitignore first, then create or enhance accordingly.
Check if .gitignore already exists
First, check if .gitignore exists in the project root:
ls -la <path-to-root>/.gitignore Option A: No .gitignore exists
If .gitignore does not exist, create it using the script at scripts/create_gitignore.py:
# Create .gitignore in project root
python <path-to-this-skill>/django-setup/scripts/create_gitignore.py --output .Verify creation at project root:
ls -la <path-to-root>/.gitignore # Should exist at project root
cat <path-to-root>/.gitignore # Review contentsOption B: .gitignore already exists
If .gitignore already exists, enhance it manually by reading both files and merging missing entries:
- Read the existing .gitignore to understand what's already covered
- Read the template at
.claude/skills/django-setup/examples/.gitignore-template - Compare both files to identify missing entries from the template
- Use the Edit tool to append missing sections/entries to the existing .gitignore, preserving the existing content
- Avoid duplicates - only add entries that don't already exist (case-insensitive comparison)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

