Skip to content
Skills Library
Programming · Building & coding

django

/django

Django batteries-included Python framework. Covers models, views, templates, ORM, and admin. Use when building full-featured Python web applications. USE WHEN: user mentions "django", "django orm", "django admin", "django templates", asks about "python cms", "django rest framework", "drf", "django models", "django migrations", "django channels", "django forms" DO NOT USE FOR: FastAPI projects - use `fastapi` instead, Flask projects - use `flask` instead, async-first Python APIs, microservices without admin panel

Licence
MIT
Last repository change
21.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
4
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 21.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Django batteries-included Python framework. Covers models, views, templates, ORM, and admin. Use when building full-featured Python web applications. USE WHEN: user mentions "django", "django orm", "django admin", "django templates", asks about "python cms", "django rest framework", "drf", "django models", "django migrations", "django channels", "django forms" DO NOT USE FOR: FastAPI projects - use `fastapi` instead, Flask projects - use `flask` instead, async-first Python APIs, microservices without admin panel

Triggers from the description

djangodjango ormdjango admindjango templatespython cmsdjango rest frameworkdrfdjango models
Original author description

Django batteries-included Python framework. Covers models, views, templates, ORM, and admin. Use when building full-featured Python web applications. USE WHEN: user mentions "django", "django orm", "django admin", "django templates", asks about "python cms", "django rest framework", "drf", "django models", "django migrations", "django channels", "django forms" DO NOT USE FOR: FastAPI projects - use `fastapi` instead, Flask projects - use `flask` instead, async-first Python APIs, microservices without admin panel

How it works

  1. Model Definition
  2. Views (Class-Based)
  3. Django REST Framework
  4. Key Commands
  5. Project Structure
  6. When NOT to Use This Skill
  7. Anti-Patterns
  8. Quick Troubleshooting
  9. Production Readiness
  10. Reference Documentation
Original SKILL.md headings · 238 lines, 753 words
SKILL.md preview
---
name: django
description: |
  Django batteries-included Python framework. Covers models, views,
  templates, ORM, and admin. Use when building full-featured Python
  web applications.

  USE WHEN: user mentions "django", "django orm", "django admin", "django templates",
  asks about "python cms", "django rest framework", "drf", "django models",
  "django migrations", "django channels", "django forms"

  DO NOT USE FOR: FastAPI projects - use `fastapi` instead, Flask projects - use `flask` instead,
  async-first Python APIs, microservices without admin panel
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Django Core Knowledge

> **Full Reference**: See [advanced.md](advanced.md) for Django Channels setup, WebSocket consumers, JWT authentication middleware, broadcasting from views, room management, and WebSocket testing.

> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `django` for comprehensive documentation.

## Model Definition

```python
from django.db import models

class User(models.Model):
    name = models.CharField(max_length=100)
    email = models.EmailField(unique=True)
    created_at = models.DateTimeField(auto_now_add=True)
    is_active = models.BooleanField(default=True)

    class Meta:
        ordering = ['-created_at']

    def __str__(self):
        return self.name
```

## Views (Class-Based)

```python
from django.views.generic import ListView, DetailView, CreateView
from django.urls import reverse_lazy

class UserListView(ListView):
    model = User
    template_name = 'users/list.html'
    context_object_name = 'users'
    paginate_by = 20

class UserDetailView(DetailView):
    model = User
    template_name = 'users/detail.html'

class UserCreateView(CreateView):
    model = User
    fields = ['name', 'email']
    success_url = reverse_lazy('user-list')
```

## Django REST Framework

```python
from rest_framework import viewsets, serializers

class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ['id', 'name', 'email', 'created_at']

class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer
```

## Key Commands

```bash
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
```

## Project Structure

```
myproject/
├── manage.py
├── myproject/
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
└── users/
    ├── models.py
    ├── views.py
    ├── urls.py
    └── admin.py
```

## When NOT to Use This Skill

- **FastAPI projects** - FastAPI is async-first with automatic OpenAPI docs
- **Flask microservices** - Django is heavyweight for simple APIs
- **Non-Python backends** - Use language-appropriate frameworks
- **Real-time only apps** - Consider Node.js or Go for WebSocket-heavy apps
- **Serverless functions** - Django startup time is too slow

## Anti-Patterns

| Anti-Pattern | Why It's Bad | Solution |
|--------------|--------------|----------|
| N+1 queries | Slow performance | Use `select_related()` and `prefetch_related()` |
| No index on frequently queried fields | Slow queries | Add `db_index=True` to model fields |
| Using `.filter()` in loops | Multiple DB hits | Use `.filter(id__in=list)` |
| Storing sensitive data in settings.py | Security risk | Use environment variables |
| Missing CSRF protection | XSS vulnerability | Keep `CsrfViewMiddleware` enabled |
| Fat models | Hard to test | Move business logic to services |

## Quick Troubleshooting

| Problem | Diagnosis | Fix |
|---------|-----------|-----|
| "No such table" error | Migrations not applied | Run `python manage.py migrate` |
| Static files not loading | STATIC_URL misconfigured | Run `collectstatic` in production |
| CSRF verification failed | Missing CSRF token | Add `{% csrf_token %}` to forms |
| "OperationalError: database is locked" | SQLite concurrency | Use PostgreSQL in production |
| Circular import errors | Models importing each other | Use `get_model()` or string references |
| Slow admin interface | No list_select_related | Add `list_select_related` to ModelAdmin |

## Production Readiness

### Security Configuration

```python
# settings/production.py
DEBUG = False
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS')
SECRET_KEY = env('SECRET_KEY')

# Security headers
SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 31536000
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_CONTENT_TYPE_NOSNIFF = True
X_FRAME_OPTIONS = 'DENY'

# Session security
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
CSRF_COOKIE_SECURE = True
```

### Caching

```python
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.redis.RedisCache',
        'LOCATION': env('REDIS_URL'),
    }
}

# Usage
from django.views.decorators.cache import cache_page

@cache_page(60 * 15)  # 15 minutes
def my_view(request):
    ...
```

### Health Checks

```python
from django.http import JsonResponse
from django.db import connection

def health_check(request):
    return JsonResponse({'status': 'healthy'})

def ready_check(request):
    try:
        connection.ensure_connection()
        return JsonResponse({'status': 'ready', 'database': 'connected'})
    except Exception as e:
        return JsonResponse({'status': 'not ready', 'error': str(e)}, status=503)
```

### Gunicorn Configuration

```python
# gunicorn.conf.py
import multiprocessing

workers = multiprocessing.cpu_count() * 2 + 1
worker_class = 'uvicorn.workers.UvicornWorker'  # For async
bind = '0.0.0.0:8000'
max_requests = 1000
timeout = 30
```

### Testing

```python
import pytest
from django.test import Client

@pytest.fixture
def authenticated_client(django_user_model):
    user = django_user_model.objects.create_user(
        username='test', password='test123'
    )
    client = Client()
    client.force_login(user)
    return client

@pytest.mark.django_db
class TestUserAPI:
    def test_create_user(self, api_client):
        response = api_client.post('/api/users/', {
            'name': 'John', 'email': 'john@example.com'
        }, content_type='application/json')
        assert response.status_code == 201
```

### Monitoring Metrics

| Metric | Target |
|--------|--------|
| Response time (p99) | < 200ms |
| Error rate (5xx) | < 0.1% |
| Database connections | < pool size |
| Cache hit ratio | > 80% |

### Checklist

- [ ] DEBUG=False in production
- [ ] Security headers enabled
- [ ] HTTPS enforced (SSL redirect)
- [ ] Database connection pooling
- [ ] Redis caching configured
- [ ] Structured JSON logging
- [ ] Health/readiness endpoints
- [ ] Gunicorn with workers
- [ ] Static files on CDN
- [ ] pytest with fixtures

## Reference Documentation

- [Models & ORM](quick-ref/models.md)
- [Views Patterns](quick-ref/views.md)
Files in this package (4)
  • SKILL.md 7 KB
  • advanced.md 7 KB
  • quick-ref/models.md 3 KB
  • quick-ref/views.md 4 KB

Versions

RepositoryScoreLicence
This page · claude-dev-suite/claude-dev-suite100MIT
ericrisco/rsc-harness100MIT
TerminalSkills/skills100Apache-2.0
nimadorostkar/Claude-Skills-collection100MIT
G1Joshi/Agent-Skills100MIT
chrishuffman5/domain-expert100MIT
ar4mirez/samuel100MIT
clawic/skills90MIT
dkbnull/hello-skill90MIT

Database snapshot: 13.11.2026 · package version e2ab69debb29 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100django-expert
    Expert-level Django development for robust Python web applications with ORM, admin, and authentication. Use when the user mentions Python, web, ORM, MVC, or Django REST Framework, or when the task involves Django Architecture.
  • 100python-django-drf
    Use this skill when developing database-driven backends using Django ORM, migrations, and Django REST Framework viewsets.
  • 95agent-django-fastapi-expert
    Specialist subagent: Django ORM, Django REST Framework, FastAPI async patterns, and Pydantic v2 specialist. Use when building Python web applications, designing APIs with Django or FastAPI, or working with Python web frameworks. Trigger phrases: Django, FastAPI, DRF, Django REST…
  • 90python-django-architecture
    Use this skill when the user says 'Django structure', 'Django architecture', 'Django apps', 'Django clean arch', 'Django ORM', 'Django REST framework', 'DRF', or when building a Django application. This skill enforces: one Django app per bounded context, service layer pattern…
  • 100django-expert
    Use when building Django web applications or REST APIs with Django REST Framework. Invoke when working with settings.py, models.py, manage.py, or any Django project file. Creates Django models with proper indexes, optimizes ORM queries using select_related/prefetch_related,…
  • 100django-expert
    Use when building Django web applications or REST APIs with Django REST Framework. Invoke when working with settings.py, models.py, manage.py, or any Django project file. Creates Django models with proper indexes, optimizes ORM queries using select_related/prefetch_related,…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.