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),` ...