django-tdd

Establish a pytest-django TDD workflow for Django models and DRF APIs.

1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill django-tdd-khetansarvesh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: django-tdd
Source: https://github.com/khetansarvesh/ai_skills_repo/tree/main/skills/django-tdd
Command: npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill django-tdd-khetansarvesh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid brittle Django changes by establishing a repeatable test-driven workflow for models, views, serializers, and DRF APIs.

Core Features & Use Cases

  • Red-Green-Refactor TDD workflow: Guides you to write failing tests first, implement the minimum code to pass, then refactor safely.
  • pytest-django setup and fast test configuration: Provides pytest settings that speed up feedback loops by using an in-memory SQLite database, reusing the DB, and disabling migrations.
  • Test data and API testing patterns: Shows how to use factory_boy for consistent fixtures, validate Django model behavior, and test Django REST Framework endpoints (including auth, create/update/delete, filtering, and search).
  • Mocking best practices: Demonstrates how to patch external services and email sending to keep tests deterministic.

Use case: You are adding a new Products API endpoint with authentication, filtering, and validation, and you want a dependable suite of unit + integration tests that runs quickly in CI.

Quick Start

Use the django-tdd skill to generate a complete pytest + factory_boy test scaffold for your Django models and DRF API endpoints and follow the red-green-refactor cycle until coverage and behavior match your requirements.

Frequently Asked Questions about django-tdd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up pytest-django for fast test-driven development?

Fast pytest-django test configuration uses an in-memory SQLite database, reuses the existing database, and disables migrations to speed up feedback loops during test-driven development.

What is the best way to test Django REST Framework APIs with factory_boy?

Testing Django REST Framework APIs with factory_boy involves creating deterministic fixtures to validate endpoint behavior, including authentication, create/update/delete operations, filtering, and search.

How do I mock external services in Django tests?

Mocking external services in Django tests involves patching external calls and email sending to keep test suites deterministic and prevent unintended side effects during execution.

Can I use the red-green-refactor TDD workflow for Django models and serializers?

The red-green-refactor TDD workflow applies to Django models and serializers by guiding you to write failing tests first, implement the minimum code to pass, and then refactor safely.

Does test coverage configuration require disabling migrations in pytest?

Disabling migrations in pytest is part of the fast test configuration setup to speed up feedback loops, complementing the configuration of test coverage goals for Django applications.