From 7fc3f8e14d1cdf2fb21524e5efffdf562068e17b Mon Sep 17 00:00:00 2001 From: Michael Vignotto Date: Wed, 3 Jun 2020 21:35:10 +0200 Subject: [PATCH] Fixed some Shit --- .../__pycache__/views.cpython-37.pyc | Bin 2112 -> 2069 bytes cocktail_list/templates/cerca.html | 4 ++-- cocktail_list/views.py | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cocktail_list/__pycache__/views.cpython-37.pyc b/cocktail_list/__pycache__/views.cpython-37.pyc index 7fa50e7fd0c8a2bcb7c96a62a3da52f1723e8642..497a0a19611a0ead32514cca88caf222bb135e40 100644 GIT binary patch delta 400 zcmXAjKT88K7>Dz_Ke_bUYfswYq=;2Zr634SP94O>4k~mI3JTI!)Cx+^4h|^}b#BLr2z?~!-XXhwOId(t+<=J^EP{=Mk+-?A#`N9)|$6Kob6wSN+g0dMq�L#w_Z*7 z5rP(7aU$cJ)CmX^4A8eUh9K)im^*j&vZj$Jawb?8yV1bWc9PMywz|G{$i2qI8rZ$& zj_5mGmwO<2jU-DR-{fj&SKFlS?1Aj(w4jWZL%SvZ^U!Ju5-m~pH$Tz)w)sP!Zs#EG z?Ehe?j`qUw>0x|en(_jHd6O&VS5`4^=Dh8t3ZHH8JdYRxK5|@&?IT2FmD05pS9q@; lnu)hoj;A=s#T2C!DWxWJil!)IW;eqP!1`z0p?N!$%RtNjQ4eVQ zfxbt_uLs?;Yc?Y|(HDm%zj|Q}!U!b_=}>{>q0HYGid2Q3D0Dxl%}A7TqC!^c$0vu{ zk{)4A?7k~?(Qvu~gj03ol#~6~X$l4y$x`u*_dpzf-k$90FU1aI2B;GX*)(u)fm38J zRcVUU32Hb~DK?(yO7;Yap6EtfV;tx3Z8JpE|1ux-QGW2LsbwsZdh DzWH8l diff --git a/cocktail_list/templates/cerca.html b/cocktail_list/templates/cerca.html index f9db402..44af7ac 100644 --- a/cocktail_list/templates/cerca.html +++ b/cocktail_list/templates/cerca.html @@ -12,9 +12,9 @@

In totale nel nostro Salone Bar abbiamo trovato {{ cocktail.count }} cocktails {% if cocktail.count == 1 %} che corrisponde {% else %} che corrispondono {% endif %} alla tua ricerca

-{% for cocktails in cocktail %} -
+ + {% for cocktails in cocktail %} {% if forloop.first %}
{% endif %} diff --git a/cocktail_list/views.py b/cocktail_list/views.py index 4d321c1..da15fde 100644 --- a/cocktail_list/views.py +++ b/cocktail_list/views.py @@ -1,7 +1,6 @@ from django.shortcuts import render,get_object_or_404,redirect from .models import Cocktail,Ingredienti,Strumenti,Bicchieri import random -import time # Create your views here. @@ -63,14 +62,12 @@ def bicchieri_cocktail(request): def cerca(request): if "q" in request.GET: querystring = request.GET.get("q") - if len(querystring) == 0: + if len(querystring) < 3: return redirect("cerca") all_ingredients = Cocktail.objects.all() searching_ingred = Cocktail.objects.none() for one_ingredient in querystring.split(","): - print(one_ingredient) searching_ingred = searching_ingred.union(searching_ingred, all_ingredients.filter(ingredienti__ingrediente__icontains=one_ingredient)) - print(searching_ingred) # ingrediente = Cocktail.objects.filter(ingredienti__ingrediente__icontains=querystring).order_by("-nome_cocktail") cocktail = Cocktail.objects.filter(nome_cocktail__icontains=querystring).order_by("-nome_cocktail") context = {"querystring":querystring,"cocktail":cocktail,"ingrediente":searching_ingred}