django-patterns
Arquitectura production-grade Django - models, views, serializers, signals, caching. Usar cuando se trabaje con Django/DRF.
Works with
---
name: django-patterns
description: Arquitectura production-grade Django - models, views, serializers, signals, caching. Usar cuando se trabaje con Django/DRF.
license: MIT
---
# Django Patterns
## Settings Split
```
settings/
├── base.py # Común
├── development.py # DEBUG=True
├── production.py # Security, caching
└── test.py # Fast, SQLite
```
## QuerySet Optimization
```python
# SIEMPRE usar select_related (FK) y prefetch_related (M2M)
User.objects.select_related('profile').prefetch_related('orders__items')
# Bulk operations
User.objects.bulk_create([User(name=n) for n in names])
User.objects.filter(active=False).update(status='inactive')
```
## Service Layer
```python
class OrderService:
@staticmethod
def create_order(user: User, items: list[dict]) -> Order:
with transaction.atomic():
order = Order.objects.create(user=user)
OrderItem.objects.bulk_create([...])
send_confirmation.delay(order.id)
return order
```
## DRF Serializers
```python
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ['id', 'name', 'email']
read_only_fields = ['id']
```
## Signals
```python
@receiver(post_save, sender=Order)
def notify_on_order(sender, instance, created, **kwargs):
if created:
send_notification.delay(instance.id)
```
## Caching
```python
@cache_page(60 * 15)
def product_list(request): ...
```More Performance skills
seo-audit
coreyhaines31/marketingskills
When the user wants to audit, review, or diagnose SEO issues on their site. Also use when the user mentions "SEO audit," "technical SEO," "why am I not ranking," "SEO issues," "on-page SEO," "meta tags review," "SEO health check," "my traffic dropped," "lost rankings," "not showing up in Google," "site isn't ranking," "Google update hit me," "page speed," "core web vitals," "crawl errors," or "indexing issues." Use this even if the user just says something vague like "my SEO is bad" or "help with SEO" — start with an audit. For building pages at scale to target keywords, see programmatic-seo. For adding structured data, see schema. For AI search optimization, see ai-seo.
competitor-profiling
coreyhaines31/marketingskills
When the user wants to research, profile, or analyze competitors from their URLs. Also use when the user mentions 'competitor profile,' 'competitor research,' 'competitor analysis,' 'profile this competitor,' 'analyze competitor,' 'competitive intelligence,' 'competitor deep dive,' 'who are my competitors,' 'competitor landscape,' 'competitor dossier,' 'competitive audit,' or 'research these competitors.' Input is a list of competitor URLs. Output is structured competitor profile markdown files. For creating comparison/alternative pages from profiles, see competitors. For sales-specific battle cards, see sales-enablement.
prospecting
coreyhaines31/marketingskills
When the user wants to find, qualify, and build a list of prospects to reach out to — across B2B SaaS, general B2B, or local small businesses. Also use when the user mentions "prospecting," "build a prospect list," "find prospects," "find leads," "lead gen list," "find SaaS companies that," "find B2B companies," "find local businesses," "ICP-fit accounts," "who should we go after," "outbound list," "target account list," "find clients near me," "businesses without websites," "prospect research," "qualified leads," "find my first customers," "early adopters," "design partners," "beta users," or "who has this problem." Use this for the list-building and qualification phase. For writing the outbound copy after the list is built, see cold-email. For deep competitive research on specific accounts, see competitor-profiling.

