Django + DRF

Enforce Django 5.x and DRF layered architecture with services and selectors.

1|Updated May 2, 2026
One-click install
npx skills add https://github.com/Levironexe/architect --skill django-drf-levironexe
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Django + DRF
Source: https://github.com/Levironexe/architect/tree/main/skills/stacks/django
Command: npx skills add https://github.com/Levironexe/architect --skill django-drf-levironexe

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Architect fixes risky, “vibe-coded” Django/DRF projects by enforcing a safe, testable separation between models, services/selectors, and thin API views. It helps prevent fragile refactors where business logic is scattered across Model.save(), serializers, or views, making behavior unpredictable and hard to change.

Core Features & Use Cases

  • Layered architecture blueprint: Defines a services/selectors pattern with required files for models, write operations, read-only queries, DRF API views, and URL routing.
  • Phased refactoring guardrails: Guides a coding agent to reorganize code into the correct layer boundaries while preserving behavior, including explicit rules for error handling and security.
  • Concrete anti-pattern detection: Flags critical issues like orchestration inside Model.save()/delete and raw ORM queries inside views, steering fixes toward services and selectors instead.

Use Case: You inherit a Django REST API where endpoints contain ORM logic, serializers trigger side effects, and domain rules are hidden in model methods; use this Skill to restructure into thin views, explicit services, and reusable selectors with consistent errors and permissions.

Quick Start

Provide your project’s Django entry points and run an agent plan that rewrites each app to match the required structure (models.py, services.py, selectors.py, apis.py, and urls.py) while moving business logic out of models/serializers and into services.

Frequently Asked Questions about Django + DRF

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

FAQPage Schema
How do I move business logic out of Django models and serializers?

To move business logic out of Django models and serializers, enforce a layered architecture using a services and selectors pattern. This separates write operations into services and read queries into selectors, keeping DRF views thin and preventing side effects in serializers.

What is the best way to structure a Django REST Framework API for safe refactoring?

The best way to structure a Django REST Framework API for safe refactoring is adopting a layered separation with required files for models, services, selectors, APIs, and URLs. This makes behavior predictable and standardizes error handling and permissions across endpoints.

Why does putting ORM queries in DRF views make my Django app fragile?

Putting ORM queries in DRF views makes your Django app fragile because it scatters domain rules and data access across the presentation layer. Moving raw queries into dedicated selectors centralizes read operations and makes API behavior predictable during refactoring.

How do I standardize error handling across Django REST Framework endpoints?

You standardize error handling across Django REST Framework endpoints by implementing domain exceptions with a consistent DRF exception handler. This ensures uniform error responses while keeping business logic isolated within the service layer.

Can I refactor Django apps into services and selectors without breaking existing API behavior?

Yes, you can refactor Django apps into services and selectors without breaking existing API behavior by using phased refactoring guardrails. These guide reorganization into correct layer boundaries while preserving functionality and applying consistent permission classes.

When should I not use a services pattern in Django?

You should reconsider using a services pattern in Django if your project is a simple CRUD application without complex domain rules. The added layer separation provides the most value when refactoring large apps where scattered logic in Model.save methods creates unpredictable behavior.