Expert Django 6.0 web framework guidance. Generate models, views, URLs, forms, admin, templates, middleware, and deployment configurations. Triggers on: django, model, queryset, view, cbv, fbv, urlpattern, orm, migration, admin, middleware, template, form, serializer, settings, deployment, wsgi, asgi
Generate production-grade Django code following official best practices.
Identify what the user needs:
| Need | Pattern | When | |------|---------|------| | CRUD pages | Generic CBVs (ListView, DetailView, CreateView, UpdateView, DeleteView) | Standard model operations | | Custom logic | Function-based views | Complex workflows, non-standard responses | | API endpoints | JsonResponse + FBV or DRF | REST API without templates | | Data modeling | Models + Managers + QuerySets | Database schema design | | Background tasks | Celery + Django | Async processing | | Real-time | Django Channels | WebSockets, SSE | | Full-text search | SearchVector + SearchQuery | PostgreSQL text search |
Apply Django conventions:
get_object_or_404() not manual try/exceptreverse() and named URLs over hardcoded pathsCheck against Django best practices:
__str__() and Meta classpath() with typed convertersApply performance patterns:
select_related() for FK, prefetch_related() for M2Monly() / defer() for partial field loadingQuerySet.iterator() for large result sets@cache_page or low-level cache APIbulk_create() / bulk_update() for batch operations| Task | Code |
|------|------|
| New project | django-admin startproject mysite |
| New app | python manage.py startapp myapp |
| Run server | python manage.py runserver |
| Make migrations | python manage.py makemigrations |
| Apply migrations | python manage.py migrate |
| Create superuser | python manage.py createsuperuser |
| Shell | python manage.py shell |
| Collect static | python manage.py collectstatic |
| Run tests | python manage.py test |
| Check deployment | python manage.py check --deploy |
select_related() / prefetch_related()reverse() and {% url %} tagsettings.py for secrets: Use environment variablesDEBUG=True in production: Split settings by environmentobjects.all() in templates: Query in views, pass via context| Tip | Impact |
|-----|--------|
| select_related / prefetch_related | Eliminates N+1 queries |
| Database indexes | 10-100x faster filtered queries |
| only() / defer() | Reduces memory for large models |
| iterator() | Streams large querysets |
| bulk_create / bulk_update | Batch DB operations |
| Template fragment caching | Reduces template rendering time |
| @cache_page decorator | Full page caching |
| File | Content | |------|---------| | models-orm.md | Models, fields, relationships, querysets, managers | | views.md | FBVs, CBVs, generic views, mixins, async views | | urls-routing.md | URL patterns, converters, namespaces, includes | | forms-admin.md | Forms, ModelForm, formsets, admin customization | | settings-deployment.md | Settings, middleware, security, ASGI/WSGI, deployment |
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer