django-model

Community

Build Django models with Counterpart patterns, effortlessly.

Authorjprokay-counterpart
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Django model creation can be complex, especially when adhering to specific architectural patterns like UUID primary keys, audit fields, and Pydantic validation for JSON fields. This Skill standardizes the process, preventing common errors and ensuring consistency across your codebase, allowing you to focus on business logic.

Core Features & Use Cases

  • Pattern-Compliant Models: Automatically generate models inheriting from BaseModel with UUID PKs and audit timestamps, ensuring architectural consistency.
  • Pydantic JSON Validation: Implement robust, type-safe validation for JSON fields using Pydantic schemas, reducing data integrity issues.
  • Relationship Management: Correctly define foreign keys, one-to-many, and many-to-many relationships with proper on_delete behavior and related_name for efficient querying.
  • Use Case: When starting a new feature that requires a new database table, use this Skill to quickly scaffold a model that perfectly fits your project's established patterns, complete with audit fields and complex JSON data validation, saving development and review time.

Quick Start

Define a Pydantic model for JSON field validation

from pydantic import BaseModel as PydanticBaseModel, Field class CoverageDetailSchema(PydanticBaseModel): coverage_type: str = Field(..., description="Type of coverage") limit: float = Field(..., gt=0, description="Coverage limit")

Create the Django model inheriting from common.models.BaseModel

from django.db import models from common.models import BaseModel # Assumes BaseModel exists from pydantic import PydanticEncoder class PolicyCoverage(BaseModel): coverage_name: str = models.CharField(max_length=100) coverage_details = models.JSONField( default=dict, encoder=PydanticEncoder, help_text="Coverage details as validated JSON" )

Dependency Matrix

Required Modules

djangopydanticpsycopg2-binary

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: django-model
Download link: https://github.com/jprokay-counterpart/jprokay-counterpart/archive/main.zip#django-model

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.