From af812a1b1fe25b567b5bc182858207b42e3f1239 Mon Sep 17 00:00:00 2001 From: "jp.av.dev" Date: Fri, 2 Jul 2021 22:14:30 -0400 Subject: [PATCH] Update '4_Formularios' --- 4_Formularios.md | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/4_Formularios.md b/4_Formularios.md index 92d7cee..cb4fec9 100644 --- a/4_Formularios.md +++ b/4_Formularios.md @@ -11,7 +11,7 @@ ### Creacion del formulario */TiendaOnline/gestionPedidos/templates/busqueda_prods.html* -``` +```html Búsqueda de productos @@ -28,7 +28,7 @@ ### Creación vista formulario *gestionPedidos/views.py* -``` +```py from django.shortcuts import render # Create your views here. @@ -39,7 +39,7 @@ def busqueda_productos(request): ### Restistrar url *(path)* *urls.py* -``` +```py ... from gestionPedidos import views @@ -51,7 +51,7 @@ urlpatterns = [ ### Crear vista para el *submit* 'buscar' *gestionPedidos/views.py* -``` +```py ... from django.http import HttpResponse @@ -63,7 +63,7 @@ def buscar(request): ### Registrar url *urls.py* -``` +```py ... urlpatterns = [ @@ -79,7 +79,7 @@ urlpatterns = [ ### Busqueda en BBDD *views.py* -``` +```py ... from gestionPedidos.models import Articulos @@ -101,7 +101,7 @@ def buscar(request): *resultado_busqueda.html* -``` +```html

Estás buscando {{query}}

{% if articulos %} @@ -120,7 +120,7 @@ def buscar(request): ### Limitar cantidad de caracteres en busqueda *views.py* -``` +```py ... def buscar(request): @@ -137,11 +137,8 @@ def buscar(request): ### Formulario de contacto -*views.py* - - *contacto.html* -``` +```html

Formulario de contacto

@@ -160,13 +157,13 @@ def buscar(request): *This should not be done for POST forms that target external URLs, since that would cause the CSRF token to be leaked, leading to a vulnerability.* *gracias.html* -``` +```html ...

Gracias por contactarnos

... ``` *views.py* -``` +```py ... def contacto(request): if request.method == "POST": @@ -175,7 +172,7 @@ def contacto(request): ``` *urlpatterns urls.py* -``` +```py ... path('contacto/', views.contacto),` ...