ahora si +views.py
This commit is contained in:
parent
a9f01f8dc9
commit
a930e4e1ec
27
TiendaOnline/gestionPedidos/views.py
Normal file
27
TiendaOnline/gestionPedidos/views.py
Normal file
@ -0,0 +1,27 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
from gestionPedidos.models import Articulos
|
||||
|
||||
# Create your views here.
|
||||
def busqueda_productos(request):
|
||||
return render(request, "busqueda_prods.html")
|
||||
|
||||
def buscar(request):
|
||||
# Validación campo vacio
|
||||
if request.GET["prod"]:
|
||||
prod_buscar = request.GET["prod"]
|
||||
if len(prod_buscar) > 20:
|
||||
msj = "Termino de búsqueda demasiado largo"
|
||||
else:
|
||||
articulos = Articulos.objects.filter(nombre__icontains=prod_buscar)
|
||||
return render(request, "resultado_busqueda.html", {"articulos":articulos, "query":prod_buscar})
|
||||
else:
|
||||
msj = "Debes introducir un termino de búsqueda"
|
||||
return HttpResponse(msj)
|
||||
|
||||
|
||||
def contacto(request):
|
||||
if request.method == "POST":
|
||||
return render(request, "gracias.html")
|
||||
return render(request, "contacto.html")
|
||||
|
Loading…
Reference in New Issue
Block a user