Django

From CodeAtCode/oss-ai-skills · View interactive version

Django is an AI agent skill from the GitHub repository CodeAtCode/oss-ai-skills. Use when building Django applications - security hardening, authentication and permissions, ORM optimization, PostgreSQL features, Django 6.0, migrations, testing, and ecosystem libraries

How to use this skill

Skill file

Objective: Use this skill to reduce N+1 query incidents, SQL-injection exposure, migration-drift breakages, permission-bypass incidents by enforcing ORM loading discipline, parameterized-query rules, migration-contract checks, permission-decorator patterns below.

Django

Comprehensive guide to Django covering security, ORM, PostgreSQL, GeoDjango, Django 6.0 essentials, admin extensions, and ecosystem tools.

Overview

Django provides a batteries-included web framework with robust features out of the box:

Specialized Skills

For deeper coverage of specific domains, see these dedicated skills:


Deep Dives

Load these reference files on demand for detailed coverage:

Best Practices (Do X Because Y)

  1. Always use {% csrf_token %} in POST forms because missing tokens allow malicious sites to submit forms on behalf of authenticated users (CSRF attacks)
  2. Enable HTTPS with SECURE_SSL_REDIRECT = True because unencrypted connections expose session cookies and user data to network eavesdroppers
  3. Enable HSTS with SECURE_HSTS_SECONDS because browsers that once visited over HTTPS should never fall back to HTTP (prevents downgrade attacks)
  4. Set SESSION_COOKIE_SECURE = True because cookies sent over HTTP can be intercepted and reused by attackers
  5. Use @login_required or PermissionRequiredMixin because unprotected views expose sensitive data to unauthenticated users
  6. Validate file uploads with ALLOWED_EXTENSIONS because malicious file uploads can execute server-side code (RCE)
  7. Never interpolate user input into raw SQL - use ORM or %s formatting because string interpolation enables SQL injection attacks
  8. Use select_related for FK relationships because accessing FK without it fires N+1 queries (one per row in templates)
  9. Use prefetch_related for M2M/reverse FK because JOINs without prefetching duplicate objects and explode memory usage
  10. Audit dead references after field renames because admin list_display, forms, and serializers silently break with old field names

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.