Fixed some Shit
parent
5c449851ac
commit
7fc3f8e14d
Binary file not shown.
|
@ -12,9 +12,9 @@
|
|||
<div class="card mt-3">
|
||||
<div class="card-header">
|
||||
<h1 class="text-center text-muted">In totale nel nostro Salone Bar abbiamo trovato {{ cocktail.count }} cocktails {% if cocktail.count == 1 %} che corrisponde {% else %} che corrispondono {% endif %} alla tua ricerca <i class="fas fa-cocktail"></i> </h1>
|
||||
{% for cocktails in cocktail %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% for cocktails in cocktail %}
|
||||
<!-- {{ cocktail.ingredienti.all }}
|
||||
{{ cocktail.nome_cocktail }} -->
|
||||
{% if forloop.first %} <div class="row"> {% endif %}
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue