スキル一覧に戻る
Dexploarer

django-model-helper

by Dexploarer

4🍴 2📅 2026年1月15日
GitHubで見るManusで実行

SKILL.md


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

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:

    python manage.py makemigrations
    
  2. Apply migration:

    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

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です