Skip to main content
skill CX Codex

django-expert · personamanagmentlayer — Claude Code skill: what it does, how to install

django-expert guides full-stack Django development covering ORM models, views, forms, authentication, and Django REST Framework APIs.

Apache-2.0 172 installs ★ 45 updated 2026-10-12

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add personamanagmentlayer/pcl --skill django-expert -a claude-code
Open on GitHub

What django-expert does

This skill equips coding agents with conventions for building applications on top of Django's Model-View-Template architecture. It provides blueprints for configuring models with custom indexes, slug validation, and lifecycle hooks inside save().

The guidance details both class-based views like ListView or CreateView and function-based handlers with authentication decorators. It also covers ModelForm field handling and setting up Django REST Framework serializers and viewsets. Permitted agent tools include file editing and running python, django-admin, and manage.py shell commands.

Because the workflows rely on standard management tasks, a functional Python environment with the django package is required.

What it helps with

  • build Django ORM models with relations, custom indexes, and save logic
  • implement generic class-based views with form processing
  • validate user input using Django ModelForm custom validators
  • scaffold Django REST Framework serializers and API endpoints

Example prompts for the agent

  • Draft a Django Post model with author relations, status choices, and slug indexing
  • Create a PostCreateView with authentication checks and a matching ModelForm
  • Set up Django REST Framework serializers for nested Post and Comment models

How to install django-expert

1Skills CLI (Vercel)

npx skills add personamanagmentlayer/pcl --skill django-expert -a claude-code

2Manually: put the files in place

~/.claude/skills/django-expert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/django-expert/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about django-expert

How to install django-expert in Claude Code?

Run npx skills add personamanagmentlayer/pcl --skill django-expert -a claude-code in your terminal. It writes the configuration to ~/.claude/skills/django-expert/SKILL.md.

What does django-expert do?

It guides AI agents through core Django patterns, including MVT setup, ORM queries, URL routing, form handling, and REST framework endpoints.

Which tools does this skill allow?

It specifies permissions for file reading and writing alongside Bash execution limited to python, django-admin, and manage.py.

Source text

SKILL.md · Apache-2.0
---
name: django-expert
version: 1.1.0
description: >-
  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.
category: frameworks
tags: [django, python, web, orm, mvc, rest-framework]
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(python:*, django-admin:*, manage.py:*)
---

# Django Expert

Expert guidance for Django - high-level Python web framework for building secure, scalable web applications with batteries included.

## Core Concepts

### Django Architecture

- MVT (Model-View-Template) pattern
- ORM (Object-Relational Mapping)
- Admin interface
- Authentication system
- URL routing
- Template engine
- Forms and validation

### Key Components

- Models (database tables)
- Views (business logic)
- Templates (presentation)
- URLs (routing)
- Forms (user input)
- Middleware (request/response processing)

## Project Setup

```bash
# Install Django
pip install django

# Create project
django-admin startproject myproject
cd myproject

# Create app
python manage.py startapp myapp

# Run migrations
python manage.py migrate

# Create superuser
python manage.py createsuperuser

# Run server
python manage.py runserver
```

## Models

```python
# myapp/models.py
from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone

class Post(models.Model):
    STATUS_CHOICES = [
        ('draft', 'Draft'),
        ('published', 'Published'),
    ]

    title = models.CharField(max_length=200)
    slug = models.SlugField(max_length=200, unique=True)
    author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='posts')
    content = models.TextField()
    status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft')
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    published_at = models.DateTimeField(null=True, blank=True)

    class Meta:
        ordering = ['-created_at']
        indexes = [
            models.Index(fields=['-created_at']),
            models.Index(fields=['slug']),
        ]

    def __str__(self):
        return self.title

    def save(self, *args, **kwargs):
        if self.status == 'published' and not self.published_at:
            self.published_at = timezone.now()
        super().save(*args, **kwargs)

class Comment(models.Model):
    post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='comments')
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    content = models.TextField()
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        ordering = ['created_at']

    def __str__(self):
        return f'Comment by {self.author} on {self.post}'
```

## Views

```python
# myapp/views.py
from django.shortcuts import render, get_object_or_404, redirect
from django.contrib.auth.decorators import login_required
from django.views.generic import ListView, DetailView, CreateView
from django.contrib import messages
from .models import Post, Comment
from .forms import PostForm, CommentForm

# Function-based view
def post_list(request):
    posts = Post.objects.filter(status='published').select_related('author')
    return render(request, 'blog/post_list.html', {'posts': posts})

def post_detail(request, slug):
    post = get_object_or_404(Post, slug=slug, status='published')
    comments = post.comments.select_related('author')

    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.post = post
            comment.author = request.user
            comment.save()
            messages.success(request, 'Comment added successfully')
            return redirect('post_detail', slug=slug)
    else:
        form = CommentForm()

    return render(request, 'blog/post_detail.html', {
        'post': post,
        'comments': comments,
        'form': form
    })

# Class-based views
class PostListView(ListView):
    model = Post
    template_name = 'blog/post_list.html'
    context_object_name = 'posts'
    paginate_by = 10

    def get_queryset(self):
        return Post.objects.filter(status='published').select_related('author')

class PostDetailView(DetailView):
    model = Post
    template_name = 'blog/post_detail.html'
    context_object_name = 'post'

    def get_queryset(self):
        return Post.objects.filter(status='published')

class PostCreateView(CreateView):
    model = Post
    form_class = PostForm
    template_name = 'blog/post_form.html'

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

## URLs

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

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('myapp.urls')),
]

# myapp/urls.py
from django.urls import path
from . import views

app_name = 'blog'

urlpatterns = [
    path('', views.PostListView.as_view(), name='post_list'),
    path('post/<slug:slug>/', views.post_detail, name='post_detail'),
    path('post/create/', views.PostCreateView.as_view(), name='post_create'),
]
```

## Forms

```python
# myapp/forms.py
from django import forms
from .models import Post, Comment

class PostForm(forms.ModelForm):
    class Meta:
        model = Post
        fields = ['title', 'slug', 'content', 'status']
        widgets = {
            'content': forms.Textarea(attrs={'rows': 10}),
        }

    def clean_slug(self):
        slug = self.cleaned_data['slug']
        if Post.objects.filter(slug=slug).exists():
            raise forms.ValidationError('Slug already exists')
        return slug

class CommentForm(forms.ModelForm):
    class Meta:
        model = Comment
        fields = ['content']
        widgets = {
            'content': forms.Textarea(attrs={'rows': 3}),
        }
```

## Django REST Framework

```python
# Install: pip install djangorestframework

# settings.py
INSTALLED_APPS = [
    ...
    'rest_framework',
]

# serializers.py
from rest_framework import serializers
from .models import Post, Comment

class CommentSerializer(serializers.ModelSerializer):
    author = serializers.StringRelatedField()

    class Meta:
        model = Comment
        fields = ['id', 'author', 'content', 'created_at']

class PostSerializer(serializers.ModelSerializer):
    author = serializers.StringRelatedField()
    comments = CommentSerializer(many=True, read_only=True)

    class Meta:
        model = Post
        fields = ['id', 'title', 'slug', 'author', 'content',
                  'status', 'created_at', 'comments']

# views.py (API)
from rest_framework import viewsets, permissions
from rest_framework.decorators import action
from rest_framework.response import Response

class PostViewSet(viewsets.ModelViewSet):
    queryset = Post.objects.filter(status='published')
    serializer_class = PostSerializer
    permission_classes = [permissions.IsAuthenticatedOrReadOnly]

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

    @action(detail=True, methods=['post'])
    def publish(self, request, pk=None):
        post = self.get_object()
        post.status = 'published'
        post.save()
        return Response({'status': 'published'})

# urls.py (API)
from rest_framework.routers import DefaultRouter

router = DefaultRouter()
router.register(r'posts', PostViewSet)

urlpatterns = [
    path('api/', include(router.urls)),
]
```

## Admin Interface

```python
# myapp/admin.py
from django.contrib import admin
from .models import Post, Comment

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ['title', 'author', 'status', 'created_at']
    list_filter = ['status', 'created_at']
    search_fields = ['title', 'content']
    prepopulated_fields = {'slug': ('title',)}
    date_hierarchy = 'created_at'

    actions = ['make_published']

    def make_published(self, request, queryset):
        queryset.update(status='published')
    make_published.short_description = "Mark selected as published"

@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
    list_display = ['post', 'author', 'created_at']
    list_filter = ['created_at']
    search_fields = ['content']
```

## Authentication

```python
# views.py
from django.contrib.auth import login, logout
from django.contrib.auth.forms import UserCreationForm

def signup(request):
    if request.method == 'POST':
        form = UserCreationForm(request.POST)
        if form.is_valid():
            user = form.save()
            login(request, user)
            return redirect('home')
    else:
        form = UserCreationForm()
    return render(request, 'registration/signup.html', {'form': form})

# URLs
from django.contrib.auth import views as auth_views

urlpatterns = [
    path('login/', auth_views.LoginView.as_view(), name='login'),
    path('logout/', auth_views.LogoutView.as_view(), name='logout'),
    path('signup/', signup, name='signup'),
]
```

## Testing

```python
# myapp/tests.py
from django.test import TestCase, Client
from django.contrib.auth.models import User
from .models import Post

class PostModelTest(TestCase):
    def setUp(self):
        self.user = User.objects.create_user(username='test', password='test')
        self.post = Post.objects.create(
            title='Test Post',
            slug='test-post',
            author=self.user,
            content='Test content',
            status='published'
        )

    def test_post_creation(self):
        self.assertEqual(self.post.title, 'Test Post')
        self.assertEqual(str(self.post), 'Test Post')

    def test_post_slug_unique(self):
        with self.assertRaises(Exception):
            Post.objects.create(
                title='Another Post',
                slug='test-post',  # Duplicate slug
                author=self.user,
                content='Content'
            )

class PostViewTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.user = User.objects.create_user(username='test', password='test')

    def test_post_list_view(self):
        response = self.client.get('/')
        self.assertEqual(response.status_code, 200)

    def test_post_create_requires_auth(self):
        response = self.client.get('/post/create/')
        self.assertEqual(response.status_code, 302)  # Redirect to login

        self.client.login(username='test', password='test')
        response = self.client.get('/post/create/')
        self.assertEqual(response.status_code, 200)
```

## Best Practices

- Use select_related/prefetch_related to avoid N+1 queries
- Implement proper validation in forms
- Use class-based views for common patterns
- Protect against CSRF attacks (enabled by default)
- Use Django's built-in authentication
- Implement proper permission checks
- Add database indexes for frequently queried fields
- Use Django migrations for schema changes

## Resources

- Django Docs: https://docs.djangoproject.com/
- Django REST Framework: https://www.django-rest-framework.org/
- Django Packages: https://djangopackages.org/

© personamanagmentlayer · Apache-2.0 · personamanagmentlayer/pcl

Similar skills

All skills for Backend and APIs →

django-expert by other authors comes first.

django-expert https://github.com/Jeffallan django-expert guides Django 5.0 and DRF development by enforcing indexed models, ORM query optimization with select_related, and JWT authentication. CX Codex +1 4,600installs django-expert vintasoftware django-expert walks your agent through Django models, views, DRF serializers and ORM query tuning, following the framework's own conventions. CX Codex +1 5,900installs django-patterns affaan-m django-patterns guides agents on Django and DRF architecture: modular settings, custom user models, and optimized QuerySets without N+1 queries. CX Codex +1 7,100installs django-perf-review getsentry The django-perf-review skill reviews Django code for N+1 queries, unbounded querysets and missing indexes. Useful before a release or when a page slows down on large tables. CX Codex +1 3,200installs ac-django souliane ac-django is a Claude Code skill with Django 6.1 and 5.2 LTS guidance on Fat Models, migrations, and security. It guides work on models, tests, queries, and DRF setup. CX Codex +1 1,000installs django-python Mindrally django-python — a skill for Claude Code that puts the agent into Django developer mode. It pushes MVT structure, ORM usage and consistent error handling on every request. CX Codex +1 991installs django-reviewer vintasoftware django-reviewer audits Django and Python diffs for ORM traps, DRF conventions, and code style. It stays in read-only mode by default, reporting issues before touching code. CX Codex +1 191installs Django Framework pluginagentmarketplace Django Framework guides agents in building Django applications with database models, authentication workflows, and Django REST Framework endpoints. CX Codex +1 108installs

From the same set104

The whole set →
airflow-expert airflow-expert guides Apache Airflow DAG design, task dependencies, operators, sensors, and scheduling. Use it when building or reviewing data workflows. CX Codex +1 174installs cloudflare-expert cloudflare-expert is a Claude Code skill for Cloudflare Workers, CDN, edge computing, and security services. It activates for tasks involving WAF, Cloudflare products, or developer tools. CX Codex +1 174installs codeql-expert The codeql-expert skill guides CodeQL database setup, custom query writing, and vulnerability scans. Use it for SAST tasks, taint tracking, and GitHub security workflows. CX Codex +1 174installs skill-creator-expert skill-creator-expert guides you through designing, writing and checking PCL skills, from domain analysis to a frontmatter template and a quality checklist. CX Codex +1 173installs graphql-expert graphql-expert is a Claude Code skill for GraphQL schema design, resolvers, and subscriptions, with guidance on Apollo federation and N+1 queries. CX Codex +1 169installs data-mesh-expert data-mesh-expert walks the agent through data mesh work: domains own their data, products ship with contracts, governance is federated and the platform serves itself. CX Codex +1 168installs swift-expert swift-expert guides an agent through Swift work for iOS and macOS, from SwiftUI screens to async code. Use it when a task involves Combine or modern Swift features. CX Codex +1 163installs linkerd-expert linkerd-expert — a Linkerd skill for Kubernetes work: the agent installs the mesh, injects the proxy, pulls linkerd viz metrics and writes access policies. CX Codex +1 162installs

Project sponsors

Companies that keep this analytics open