style fix

This commit is contained in:
Matthias 2021-07-19 01:26:26 +02:00
parent 6ca34276bd
commit 4013abe4de

View File

@ -21,7 +21,6 @@ from django.views.generic import ListView, DetailView, CreateView, FormView, Del
from django.views.generic.base import RedirectView, TemplateView
from djmoney.contrib.exchange.models import ExchangeBackend, Rate
from rest_framework.schemas.coreapi import SchemaGenerator
from common.settings import currency_code_default, currency_codes
from part.models import Part, PartCategory
@ -773,12 +772,8 @@ class SearchResultView(TemplateView):
def get(self, request, *args, **kwargs):
query = request.GET.get('term', '')
if len(query) > 2:
objects = Part.objects.filter(
Q(name__icontains=query) |
Q(description__icontains=query) |
Q(IPN__icontains=query) |
Q(keywords__icontains=query) |
Q(category__name__icontains=query)).order_by('name')
objects = Part.objects.filter(Q(name__icontains=query) | Q(description__icontains=query) | Q(IPN__icontains=query)
| Q(keywords__icontains=query) | Q(category__name__icontains=query)).order_by('name')
return JsonResponse([{'id': a.pk, 'value': a.name} for a in objects[0:5]], safe=False)
return JsonResponse({})