Django

Django is a high-level Python web framework that encourages rapid development. It includes an ORM, template engine, admin site, form handling, authentication, and security middleware out of the box.

25 stars

Best use case

Django is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Django is a high-level Python web framework that encourages rapid development. It includes an ORM, template engine, admin site, form handling, authentication, and security middleware out of the box.

Teams using Django should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/django/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/TerminalSkills/skills/django/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/django/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How Django Compares

Feature / AgentDjangoStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Django is a high-level Python web framework that encourages rapid development. It includes an ORM, template engine, admin site, form handling, authentication, and security middleware out of the box.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Django

Django is a high-level Python web framework that encourages rapid development. It includes an ORM, template engine, admin site, form handling, authentication, and security middleware out of the box.

## Installation

```bash
# Install Django and start a project
pip install django
django-admin startproject myproject .
python manage.py startapp core
```

## Project Structure

```
# Standard Django project layout
myproject/
├── manage.py
├── myproject/
│   ├── settings.py      # Configuration
│   ├── urls.py          # Root URL config
│   ├── wsgi.py          # WSGI entry point
│   └── asgi.py          # ASGI entry point
├── core/
│   ├── models.py        # Database models
│   ├── views.py         # View functions/classes
│   ├── urls.py          # App URL patterns
│   ├── admin.py         # Admin registration
│   ├── forms.py         # Form classes
│   ├── serializers.py   # DRF serializers
│   ├── templates/       # HTML templates
│   └── tests.py
└── templates/           # Project-level templates
```

## Models

```python
# core/models.py — database models with Django ORM
from django.db import models
from django.contrib.auth.models import AbstractUser

class User(AbstractUser):
    bio = models.TextField(blank=True)
    avatar = models.ImageField(upload_to="avatars/", blank=True)

class Article(models.Model):
    title = models.CharField(max_length=200)
    slug = models.SlugField(unique=True)
    body = models.TextField()
    author = models.ForeignKey(User, on_delete=models.CASCADE, related_name="articles")
    published = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        ordering = ["-created_at"]

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

## Views

```python
# core/views.py — function-based and class-based views
from django.shortcuts import render, get_object_or_404, redirect
from django.views.generic import ListView, DetailView, CreateView
from django.contrib.auth.mixins import LoginRequiredMixin
from .models import Article
from .forms import ArticleForm

class ArticleListView(ListView):
    model = Article
    queryset = Article.objects.filter(published=True).select_related("author")
    template_name = "core/article_list.html"
    paginate_by = 20

class ArticleDetailView(DetailView):
    model = Article
    slug_field = "slug"
    template_name = "core/article_detail.html"

class ArticleCreateView(LoginRequiredMixin, CreateView):
    model = Article
    form_class = ArticleForm
    template_name = "core/article_form.html"

    def form_valid(self, form):
        form.instance.author = self.request.user
        return super().form_valid(form)
```

## URL Configuration

```python
# core/urls.py — URL patterns for the core app
from django.urls import path
from . import views

app_name = "core"
urlpatterns = [
    path("", views.ArticleListView.as_view(), name="article-list"),
    path("<slug:slug>/", views.ArticleDetailView.as_view(), name="article-detail"),
    path("new/", views.ArticleCreateView.as_view(), name="article-create"),
]
```

```python
# myproject/urls.py — root URL configuration
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path("admin/", admin.site.urls),
    path("articles/", include("core.urls")),
    path("api/", include("core.api_urls")),
]
```

## Admin

```python
# core/admin.py — admin site registration
from django.contrib import admin
from .models import Article

@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
    list_display = ["title", "author", "published", "created_at"]
    list_filter = ["published", "created_at"]
    search_fields = ["title", "body"]
    prepopulated_fields = {"slug": ("title",)}
    raw_id_fields = ["author"]
```

## Templates

```html
<!-- templates/core/article_list.html — list view template -->
{% extends "base.html" %}
{% block content %}
<h1>Articles</h1>
{% for article in object_list %}
  <article>
    <h2><a href="{{ article.get_absolute_url }}">{{ article.title }}</a></h2>
    <p>By {{ article.author.username }} — {{ article.created_at|date:"M d, Y" }}</p>
  </article>
{% empty %}
  <p>No articles yet.</p>
{% endfor %}
{% include "core/_pagination.html" %}
{% endblock %}
```

## Django REST Framework

```python
# core/serializers.py — DRF serializers
from rest_framework import serializers
from .models import Article

class ArticleSerializer(serializers.ModelSerializer):
    author_name = serializers.CharField(source="author.username", read_only=True)

    class Meta:
        model = Article
        fields = ["id", "title", "slug", "body", "author_name", "published", "created_at"]
        read_only_fields = ["slug"]
```

```python
# core/api_views.py — DRF viewsets
from rest_framework import viewsets, permissions
from .models import Article
from .serializers import ArticleSerializer

class ArticleViewSet(viewsets.ModelViewSet):
    queryset = Article.objects.filter(published=True)
    serializer_class = ArticleSerializer
    permission_classes = [permissions.IsAuthenticatedOrReadOnly]
    lookup_field = "slug"

    def perform_create(self, serializer):
        serializer.save(author=self.request.user)
```

## Migrations

```bash
# Create and apply database migrations
python manage.py makemigrations core
python manage.py migrate
python manage.py createsuperuser
```

## Settings Essentials

```python
# myproject/settings.py — key settings to configure
import os
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", "change-me")
DEBUG = os.environ.get("DEBUG", "True") == "True"
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "localhost").split(",")

AUTH_USER_MODEL = "core.User"

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": os.environ.get("DB_NAME", "mydb"),
        "USER": os.environ.get("DB_USER", "postgres"),
        "PASSWORD": os.environ.get("DB_PASSWORD", ""),
        "HOST": os.environ.get("DB_HOST", "localhost"),
    }
}

STATIC_URL = "/static/"
STATIC_ROOT = BASE_DIR / "staticfiles"
```

## Testing

```python
# core/tests.py — Django test example
from django.test import TestCase, Client
from django.urls import reverse
from .models import Article, User

class ArticleTests(TestCase):
    def setUp(self):
        self.user = User.objects.create_user(username="test", password="pass1234")
        self.article = Article.objects.create(
            title="Test", slug="test", body="Hello", author=self.user, published=True
        )

    def test_list_view(self):
        resp = self.client.get(reverse("core:article-list"))
        self.assertEqual(resp.status_code, 200)
        self.assertContains(resp, "Test")
```

## Running

```bash
# Run development server
python manage.py runserver 0.0.0.0:8000
```

## Key Patterns

- Use `select_related` and `prefetch_related` to avoid N+1 queries
- Set `AUTH_USER_MODEL` early — it's hard to change after first migration
- Use class-based views for CRUD; function views for custom logic
- Middleware order matters: SecurityMiddleware first, then SessionMiddleware
- Use `django-environ` or `os.environ` for secrets — never hardcode
- Run `python manage.py check --deploy` before production deployment

Related Skills

django-view-generator

25
from ComeOnOliver/skillshub

Django View Generator - Auto-activating skill for Backend Development. Triggers on: django view generator, django view generator Part of the Backend Development skill category.

django-perf-review

25
from ComeOnOliver/skillshub

Django performance code review. Use when asked to "review Django performance", "find N+1 queries", "optimize Django", "check queryset performance", "database performance", "Django ORM issues", or audit Django code for performance problems.

django-access-review

25
from ComeOnOliver/skillshub

Django access control and IDOR security review. Use when reviewing Django views, DRF viewsets, ORM queries, or any Python/Django code handling user authorization. Trigger keywords: "IDOR", "access control", "authorization", "Django permissions", "object permissions", "tenant isolation", "broken access".

django-pro

25
from ComeOnOliver/skillshub

Master Django 5.x with async views, DRF, Celery, and Django Channels. Build scalable web applications with proper architecture, testing, and deployment. Use PROACTIVELY for Django development, ORM optimization, or complex Django patterns.

django-verification

25
from ComeOnOliver/skillshub

Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.

django-tdd

25
from ComeOnOliver/skillshub

Django testing strategies with pytest-django, TDD methodology, factory_boy, mocking, coverage, and testing Django REST Framework APIs.

django-security

25
from ComeOnOliver/skillshub

Django security best practices, authentication, authorization, CSRF protection, SQL injection prevention, XSS prevention, and secure deployment configurations.

django-patterns

25
from ComeOnOliver/skillshub

Django architecture patterns, REST API design with DRF, ORM best practices, caching, signals, middleware, and production-grade Django apps.

django-drf

25
from ComeOnOliver/skillshub

Django REST Framework patterns. Trigger: When building REST APIs with Django - ViewSets, Serializers, Filters.

exa-core-workflow-b

25
from ComeOnOliver/skillshub

Execute Exa findSimilar, getContents, answer, and streaming answer workflows. Use when finding pages similar to a URL, retrieving content for known URLs, or getting AI-generated answers with citations. Trigger with phrases like "exa find similar", "exa get contents", "exa answer", "exa similarity search", "findSimilarAndContents".

exa-core-workflow-a

25
from ComeOnOliver/skillshub

Execute Exa neural search with contents, date filters, and domain scoping. Use when building search features, implementing RAG context retrieval, or querying the web with semantic understanding. Trigger with phrases like "exa search", "exa neural search", "search with exa", "exa searchAndContents", "exa query".

exa-common-errors

25
from ComeOnOliver/skillshub

Diagnose and fix Exa API errors by HTTP code and error tag. Use when encountering Exa errors, debugging failed requests, or troubleshooting integration issues. Trigger with phrases like "exa error", "fix exa", "exa not working", "debug exa", "exa 429", "exa 401".