admin

A Django admin setup for managing database records through Django’s built-in web dashboard.

In plain words
What is it for?
Use it to register models and customize their admin lists, forms, filters, searches, and actions.
Why use it?
It removes the need to build common management screens from scratch, including search, filters, related-record editing, and bulk actions.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/justdvp/claude-code-templates/admin
Clone the repo
git clone --depth 1 https://github.com/Justdvp/claude-code-templates

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,886 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01886
Opus 5 $0.00000 $0.00943
Sonnet 5 $0.00000 $0.00377
Haiku 4.5 $0.00000 $0.00189

Measured 2d ago against content hash f4ab922e3bd1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

admin scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

cli-tool/templates/python/examples/django-app/.claude/commands/admin.md · 264 lines

How it starts

The opening of the file, as written. The whole thing — 264 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Django Admin Configuration

Configure Django admin interface with custom admin classes and functionality.

Purpose

This command helps you create comprehensive Django admin configurations with advanced features and customizations.

Usage

/admin

What this command does

  1. Registers models with custom admin classes
  2. Creates advanced admin interfaces with filtering, search, and actions
  3. Adds inline editing for related models
  4. Customizes list displays and forms
  5. Implements admin actions for bulk operations

Example Output

# admin.py
from django.contrib import admin
from django.utils.html import format_html
from django.urls import reverse
from django.utils.safestring import mark_safe
from .models import Post, Category, Tag, Comment

@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    """Admin configuration for Category model."""
    list_display = ['name', 'slug', 'post_count', 'created_at']
    list_filter = ['created_at']
    search_fields = ['name', 'description']
    prepopulated_fields = {'slug': ('name',)}
    readonly_fields = ['created_at', 'updated_at']
    
    def post_count(self, obj):
        """Display number of posts in this category."""
        count = obj.posts.count()
        url = reverse('admin:blog_post_changelist') + f'?category__id__exact={obj.id}'
        return format_html('<a href="{}">{} posts</a>', url, count)
    post_count.short_description = 'Posts'

class CommentInline(admin.TabularInline):
    """Inline admin for comments."""
    model = Comment
    extra = 0
    readonly_fields = ['created_at', 'author']
    fields = ['author', 'content', 'is_approved', 'created_at']

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    """Advanced admin configuration for Post model."""
    list_display = [
        'title', 
        'author', 
        'category', 
        'status', 
        'view_count',
        'created_at',
        'post_preview'
    ]
    list_filter = [
        'status', 
        'category', 
        'created_at', 
        'updated_at',
        ('author', admin.RelatedOnlyFieldListFilter)
    ]
    search_fields = ['title', 'content', 'author__username']
    prepopulated_fields = {'slug': ('title',)}
    readonly_fields = ['created_at', 'updated_at', 'view_count', 'post_preview']
    
    # Custom form layout
    fieldsets = (
        ('Content', {
            'fields': ('title', 'slug', 'content', 'status')
        }),
        ('Metadata', {
            'fields': ('author', 'category', 'tags'),
            'classes': ('collapse',)
        }),
        ('SEO', {
            'fields': ('meta_description', 'meta_keywords'),
            'classes': ('collapse',)
        }),
        ('Timestamps', {
            'fields': ('created_at', 'updated_at', 'view_count'),
            'classes': ('collapse',)
        }),
    )
    
    # Many-to-many field display
    filter_horizontal = ['tags']
    
    # Inline models
    inlines = [CommentInline]
    
    # Custom list display methods
    def post_preview(self, obj):
        """Show thumbnail preview of post."""
        if obj.featured_image:
            return format_html(
                '<img src="{}" width="50" height="50" style="border-radius: 5px;" />',
                obj.featured_image.url
            )
        return "No image"
    post_preview.short_description = 'Preview'
    
    # Custom admin actions
    actions = ['make_published', 'make_draft', 'duplicate_posts']
    
    def make_published(self, request, queryset):
        """Bulk action to publish selected posts."""
        updated = queryset.update(status='published')
        self.message_user(
            request, 
            f'{updated} posts were successfully marked as published.'
        )
    make_published.short_description = "Mark selected posts as published"
    
    def make_draft(self, request, queryset):
        """Bulk action to set selected posts as draft."""
        updated = queryset.update(status='draft')
        self.message_user(
            request, 
            f'{updated} posts were successfully marked as draft.'
        )
    make_draft.short_description = "Mark selected posts as draft"
    
    def duplicate_posts(self, request, queryset):
        """Bulk action to duplicate selected posts."""
        count = 0
        for post in queryset:
            post.pk = None  # Create new instance
            post.title = f"Copy of {post.title}"
            post.slug = f"copy-of-{post.slug}"
            post.status = 'draft'
            post.save()
            count += 1
        
        self.message_user(
            request,
            f'{count} posts were successfully duplicated.'
        )
    duplicate_posts.short_description = "Duplicate selected posts"

@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
    """Admin configuration for Tag model."""
    list_display = ['name', 'slug', 'post_count', 'color_preview']
    search_fields = ['name']
    prepopulated_fields = {'slug': ('name',)}
    
    def post_count(self, obj):
        """Display number of posts with this tag."""
        return obj.posts.count()
    post_count.short_description = 'Posts'
    
    def color_preview(self, obj):
        """Show color preview if tag has color field."""
        if hasattr(obj, 'color') and obj.color:
            return format_html(
                '<span style="background-color: {}; padding: 2px 8px; border-radius: 3px; color: white;">{}</span>',
                obj.color,
                obj.name
            )
        return obj.name
    color_preview.short_description = 'Preview'

@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
    """Admin configuration for Comment model."""
    list_display = ['author', 'post', 'content_preview', 'is_approved', 'created_at']
    list_filter = ['is_approved', 'created_at', 'post__category']
    search_fields = ['content', 'author__username', 'post__title']
    readonly_fields = ['created_at', 'updated_at']
    actions = ['approve_comments', 'disapprove_comments']
    
    def content_preview(self, obj):
        """Show truncated content preview."""
        return obj.content[:50] + "..." if len(obj.content) > 50 else obj.content
    content_preview.short_description = 'Content'
    
    def approve_comments(self, request, queryset):
        """Bulk approve comments."""
        updated = queryset.update(is_approved=True)
        self.message_user(request, f'{updated} comments were approved.')
    approve_comments.short_description = "Approve selected comments"
    
    def disapprove_comments(self, request, queryset):
        """Bulk disapprove comments."""
        updated = queryset.update(is_approved=False)
        self.message_user(request, f'{updated} comments were disapproved.')
    disapprove_comments.short_description = "Disapprove selected comments"

# Custom admin site configuration
admin.site.site_header = "Blog Administration"
admin.site.site_title = "Blog Admin Portal"
admin.site.index_title = "Welcome to Blog Administration"

Read the full file on GitHub · 264 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 264 lines · 0 tokens per session scan A f4ab922e3bd1

Subscribe to this mod's changes

admin is a command published in the GitHub repository Justdvp/claude-code-templates (7 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,886 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.