Cómo llega una solicitud a su vista
WSGI, el resolvedor de URL y el camino hasta su código
Cómo llega una solicitud a su vista es una lección gratuita de Django Academy en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Django Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Django Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
It Starts with a Click
Every Django page begins as an HTTP request. A browser asks for a URL, and Django's job is to answer with a response. 🌐
The Web Server Out Front
A web server like Nginx receives the raw request first. It handles networking, then hands the request off to Django to do the real work.
WSGI: The Handshake
WSGI is the standard interface between the web server and Django. It turns the incoming request into something your Python code can read.
The WSGI Application
Django ships a callable in wsgi.py. The server calls it for each request, and Django takes over from there to route and respond.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()Middleware Runs First
Before your view, the request passes through middleware. Each layer can inspect or tweak the request, like adding security checks.
The URL Resolver
Django reads urls.py and matches the requested path against your patterns. The first pattern that matches wins the request.
urlpatterns = [
path('about/', views.about),
]Matching the Path
If the path is /about/, Django finds the matching pattern and notes which view should handle it. No match means a 404.
Calling Your View
Django calls your view function and passes it the request object. This is where your own code finally takes control.
def about(request):
return HttpResponse("Hi")The View Returns a Response
Your view must return an HttpResponse. Django takes that object and hands it back up the chain toward the browser.
Back Through Middleware
The response travels back through middleware in reverse order. Layers can add headers or compress content before it leaves.
Out to the Browser
The web server sends the finished response across the network. The browser renders it, completing one full request cycle. ✅
Quick Check
Which component matches the requested path to a view?
Recap: The Journey
A request flows from server to WSGI, through middleware, to the URL resolver, then your view, and back out as a response. That loop is Django. 🎉
Aprende Python con un tutor de IA — gratis
Escribe y ejecuta código real en tu navegador, obtén ayuda instantánea de un tutor de IA disponible 24/7 y continúa donde lo dejaste en la web o en la aplicación.
- Cursos
- 30
- Lecciones
- 120
Preguntas frecuentes
¿La lección «Cómo llega una solicitud a su vista» es gratis?
Sí — el texto completo de «Cómo llega una solicitud a su vista» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Django Academy, actualiza a CoddyKit PRO. El curso de Django Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Cómo llega una solicitud a su vista»?
WSGI, el resolvedor de URL y el camino hasta su código Practicas Django Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Django Academy?
No se requiere experiencia previa. Django Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.
¿Cuánto tiempo toma la lección «Cómo llega una solicitud a su vista»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Django Academy?
Sí. Cada lección de Django Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Cómo llega una solicitud a su vista
- El objeto HttpRequest
- Devolver un HttpResponse
- Códigos de estado y subclases de HttpResponse