django-security

Implements Django security practices for authentication, authorization, CSRF, XSS, and SQL injection prevention.

2|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/adamreger/ecc-antigravity --skill django-security-adamreger
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: django-security
Source: https://github.com/adamreger/ecc-antigravity/tree/main/skills/django-security
Command: npx skills add https://github.com/adamreger/ecc-antigravity --skill django-security-adamreger

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Django applications are vulnerable to common web attacks like SQL injection, XSS, CSRF, and misconfigured production settings. This Skill provides concrete, copy-ready security patterns so you can harden authentication, authorization, and deployment configurations without researching each vulnerability from scratch. ## Core Features & Use Cases - Production Hardening: Secure settings for DEBUG, HTTPS, HSTS, secure cookies, and environment-based secret management. - Authentication & Authorization: Custom user models, Argon2 password hashing, permission mixins, custom DRF permission classes, and role-based access control. - Attack Prevention: Safe ORM and raw SQL patterns, template escaping rules, CSRF token handling for forms and AJAX, file upload validation, API rate limiting, and Content Security Policy headers. - Use Case: Before deploying a Django app to production, use this Skill to audit your settings.py, add throttling to your REST API endpoints, and verify your templates escape user input correctly. ## Quick Start Review my Django project for security issues and apply the production security settings and CSRF protection patterns.

Frequently Asked Questions about django-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent SQL injection in Django?▼

Use the Django ORM, which automatically escapes query parameters, or pass parameters as a list to raw() queries. Never interpolate user input directly into SQL strings with f-strings or concatenation, as that creates injection vulnerabilities.

How to set up CSRF protection for Django AJAX requests?▼

Read the csrftoken cookie in JavaScript and send it as the X-CSRFToken header with your fetch or AJAX POST requests. Django enables CSRF middleware by default, and templates should include the csrf_token tag inside forms.

What password hasher should Django use in production?▼

Configure Argon2PasswordHasher as the first entry in PASSWORD_HASHERS, with PBKDF2 variants as fallbacks for existing hashes. Django defaults to PBKDF2, but Argon2 provides stronger resistance against brute-force attacks.

Does Django protect against XSS attacks by default?▼

Yes, Django templates auto-escape variables by default, converting HTML characters to safe entities. Avoid using the safe filter or mark_safe on untrusted user input, and use escapejs for values inserted into JavaScript contexts.

Why is DEBUG=True dangerous in Django production?▼

DEBUG=True exposes detailed error pages containing settings, environment variables, and stack traces to attackers. Always set DEBUG=False in production, configure ALLOWED_HOSTS, and load SECRET_KEY from environment variables.

How do I rate limit Django REST Framework APIs?▼

Configure DEFAULT_THROTTLE_CLASSES with AnonRateThrottle and UserRateThrottle in REST_FRAMEWORK settings, then set rates like 100/day for anonymous users. Create custom throttle classes with scoped rates for burst or sustained limits.