claudegoodies
Command

views

From davila7

Create Django views with proper structure and best practices.

Install

/views

Facts

Status
Actively maintained
Last commit

Source preview

The instructions Claude Code reads when this command runs.

# Django Views Generator

Create Django views with proper structure and best practices.

## Purpose

This command helps you quickly create Django views (Function-Based Views and Class-Based Views) following Django conventions.

## Usage

```
/views
```

## What this command does

1. **Creates view functions/classes** with proper structure
2. **Handles HTTP methods** (GET, POST, PUT, DELETE)
3. **Includes form handling** and validation
4. **Adds authentication/authorization** checks
5. **Follows Django best practices** and security guidelines

## Example Output

```python
# views.py
from django.shortcuts import render, get_object_or_404, redirect
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.http import JsonResponse
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse_lazy
from .models import Post, Category
from .forms import PostForm

# Function-Based Views
def post_list(request):
    """Display list of posts with pagination and filtering."""
    posts = Post.objects.filter(status='published').select_related('author', 'category')
    
    # Search functionality
    search_query = request.GET.get('search')
    if search_query:
        posts = posts.filter(title__icontains=search_query)
    
    
View full source on GitHub →

Other slash commands