Django Application

aj-geddes/useful-ai-prompts/skills/django-application

作者 aj-geddes3f5182cfd739无许可证355 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Develop production-grade Django applications with models, views, ORM queries, authentication, and admin interfaces. Use when building web applications, managing databases with Django ORM, and implementing authentication systems.

AI 生成的概览

指导构建生产级 Django Web 应用,涵盖模型、视图、ORM 查询、身份验证和管理后台。

功能
提供开发 Django Web 应用的参考指南和最佳实践,涵盖项目搭建、使用 ORM 进行模型设计、类视图与函数视图、URL 路由、身份验证与权限、数据库查询优化以及管理后台定制。其中包含快速开始的命令示例和一份该做与不该做的实践清单。此外还附带一个模式校验脚本和一个迁移模板。
适用场景
适用于创建或扩展 Django Web 应用、设计模型与数据库结构、实现视图与 URL 路由、构建身份验证与权限系统、优化 ORM 查询或定制 Django 管理后台的场景。
运行要求
需要已安装 Django 的 Python 环境,以及所构建应用使用的数据库后端。附带一个可执行的校验脚本和一个迁移模板;未说明需要凭据或网络访问。

Django Application

Table of Contents

Overview

Build comprehensive Django web applications with proper model design, view hierarchies, database operations, user authentication, and admin functionality following Django conventions and best practices.

When to Use

  • Creating Django web applications
  • Designing models and database schemas
  • Implementing views and URL routing
  • Building authentication systems
  • Using Django ORM for database operations
  • Creating admin interfaces and dashboards

Quick Start

Minimal working example:

bash
django-admin startproject myprojectcd myprojectpython manage.py startapp userspython manage.py startapp products

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Django Project Setup [blocked]Django Project Setup
Model Design with ORM [blocked]Model Design with ORM
Views with Class-Based and Function-Based Approaches [blocked]Views with Class-Based and Function-Based Approaches
Authentication and Permissions [blocked]Authentication and Permissions
Database Queries and Optimization [blocked]Database Queries and Optimization
URL Routing [blocked]URL Routing
Admin Interface Customization [blocked]Admin Interface Customization

Best Practices

✅ DO

  • Use models for database operations
  • Implement proper indexes on frequently queried fields
  • Use select_related and prefetch_related for query optimization
  • Implement authentication and permissions
  • Use Django Forms for form validation
  • Cache expensive queries
  • Use management commands for batch operations
  • Implement logging for debugging
  • Use middleware for cross-cutting concerns
  • Validate user input

❌ DON'T

  • Use raw SQL without ORM
  • N+1 query problems without optimization
  • Store secrets in code
  • Trust user input directly
  • Override init in models unnecessarily
  • Make synchronous heavy operations in views
  • Use inheritance models unless necessary
  • Expose stack traces in production

来源与署名

来源:aj-geddes/useful-ai-prompts位于skills/django-application提交3f5182c

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架