
Django Expert
Install django-expert when your solo SaaS or API needs Django REST Framework serializers and views that follow production-safe field exposure and nesting patterns.
Install
npx skills add https://github.com/vintasoftware/django-ai-plugins --skill django-expertWhat is this skill?
- Explicit field lists on ModelSerializer with read_only_fields instead of exposing every model column
- Warns against fields = '__all__' so password hashes and sensitive attributes never leak in API responses
- Nested read-only serializers for authors and comments on parent resources
- Separate serializer patterns for read vs write paths when nested data would over-fetch or allow unsafe writes
- DRF-oriented code snippets marked GOOD vs BAD for fast agent-side review
Adoption & trust: 3.9k installs on skills.sh; 82 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Journey fit
Django REST expertise applies while you are implementing server-side APIs and serializers, which is core Build work before ship-ready endpoints exist. The skill’s examples center on ModelSerializer configuration, nested read-only relations, and API shape—canonical backend subphase material.
Common Questions / FAQ
Is Django Expert safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Django Expert
# Django REST Framework Best Practices ## Serializers ### ModelSerializer Basics ```python from rest_framework import serializers from .models import Post, Comment # ✅ GOOD: Basic ModelSerializer class PostSerializer(serializers.ModelSerializer): class Meta: model = Post fields = ['id', 'title', 'content', 'author', 'created_at'] read_only_fields = ['id', 'created_at', 'author'] # ✅ GOOD: Exclude sensitive fields class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ['id', 'username', 'email', 'first_name', 'last_name'] # NOT password, last_login, etc. # ❌ BAD: Using __all__ exposes everything class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = '__all__' # Exposes password hash! ``` **Rule**: Explicitly list fields. Never use `fields = '__all__'` in production. ### Nested Serializers ```python # ✅ GOOD: Nested read-only serializer class CommentSerializer(serializers.ModelSerializer): author = UserSerializer(read_only=True) class Meta: model = Comment fields = ['id', 'content', 'author', 'created_at'] class PostSerializer(serializers.ModelSerializer): author = UserSerializer(read_only=True) comments = CommentSerializer(many=True, read_only=True) class Meta: model = Post fields = ['id', 'title', 'content', 'author', 'comments', 'created_at'] # ✅ GOOD: Different serializers for read/write class PostListSerializer(serializers.ModelSerializer): """Lightweight serializer for list view.""" author_name = serializers.CharField(source='author.username', read_only=True) class Meta: model = Post fields = ['id', 'title', 'author_name', 'created_at'] class PostDetailSerializer(serializers.ModelSerializer): """Detailed serializer with nested data.""" author = UserSerializer(read_only=True) comments = CommentSerializer(many=True, read_only=True) class Meta: model = Post fields = ['id', 'title', 'content', 'author', 'comments', 'created_at', 'updated_at'] ``` ### Custom Fields and Validation ```python # ✅ GOOD: Add computed fields class PostSerializer(serializers.ModelSerializer): comment_count = serializers.SerializerMethodField() is_author = serializers.SerializerMethodField() class Meta: model = Post fields = ['id', 'title', 'content', 'comment_count', 'is_author'] def get_comment_count(self, obj): return obj.comments.count() def get_is_author(self, obj): request = self.context.get('request') return request.user == obj.author if request else False # ✅ GOOD: Field-level validation class PostSerializer(serializers.ModelSerializer): class Meta: model = Post fields = ['title', 'content'] def validate_title(self, value): if len(value) < 5: raise serializers.ValidationError("Title must be at least 5 characters") return value # ✅ GOOD: Object-level validation class PostSerializer(serializers.ModelSerializer): class Meta: model = Post fields = ['title', 'content', 'is_published'] def validate(self, data): if data.get('is_published') and not data.get('content'): raise serializers.ValidationError( "Cannot publish post without content" ) return data ``` ### Write-Only and Read-Only Fields ```python # ✅ GOOD: Password handling class UserRegistrationSerializer(serializers.ModelSerializer): password = serializers.CharField(write_only=True, min_length=8) password_confirm = serializers.CharField(write_only=True) class Meta: model = User fields = ['username', 'email', 'password', 'password_confirm'] def validate(self, data): if data['password'] != data['password_confirm']: raise serializers.ValidationError("Passwords don't match") re