Generates Django models with proper field types, relationships, and migrations. Use when creating Django models or database schemas.
Scanned 2/10/2026
Install via CLI
openskills install majiayu000/claude-skill-registry---
name: django-model-helper
description: Generates Django models with proper field types, relationships, and migrations. Use when creating Django models or database schemas.
allowed-tools: [Write, Read, Bash]
---
# Django Model Helper
Generates Django models following best practices.
## When to Use
- "Create a Django model for users"
- "Generate Product model"
- "Add BlogPost model with relationships"
## Model Generation
```python
from django.db import models
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
"""Custom user model."""
bio = models.TextField(blank=True)
avatar = models.ImageField(upload_to='avatars/', blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'users'
ordering = ['-created_at']
def __str__(self):
return self.username
class Post(models.Model):
"""Blog post model."""
title = models.CharField(max_length=200)
slug = models.SlugField(unique=True)
author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='posts')
content = models.TextField()
published_at = models.DateTimeField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'posts'
ordering = ['-published_at']
indexes = [
models.Index(fields=['slug']),
models.Index(fields=['author', '-published_at']),
]
def __str__(self):
return self.title
```
## After Creating Model
1. Generate migration:
```bash
python manage.py makemigrations
```
2. Apply migration:
```bash
python manage.py migrate
```
## Best Practices
- Use appropriate field types
- Add indexes for frequently queried fields
- Define __str__ methods
- Use Meta class for table name and ordering
- Add related_name to relationships
- Include created_at/updated_at timestamps
- Use on_delete properly
- Add helpful docstrings
No comments yet. Be the first to comment!
MySQL development best practices for schema design, query optimization, and database administration
Spring Boot中的JPA/Hibernate实体设计、关系、查询优化、事务、审计、索引、分页和连接池模式。
基于Supabase最佳实践的PostgreSQL数据库模式,用于查询优化、架构设计、索引和安全。
ClickHouse数据库模式、查询优化、分析和数据工程最佳实践,适用于高性能分析工作负载。
Decide where to place TiDB tests and how to write them (basic structure, naming, testdata usage). Use when asked about test locations, writing conventions, shard_count limits, casetest categorization, or when reviewing test changes in code review.