active search from 3 january#90
active search from 3 january#90WebsterQR wants to merge 4 commits intoidlesign:masteridlesign/pythonz:masterfrom
Conversation
idlesign
left a comment
There was a problem hiding this comment.
Маковские директории .DS_Store нужно будет убрать из этого запроса на слияние. Они не требуются.
| <input class="form-control" autofocus type="search" aria-label="Search" name="text" placeholder="Поиск по справочнику" value="{{ search_term }}" required itemprop="query-input"> | ||
| <label for="tags"> | ||
| <input | ||
| id='tags' |
There was a problem hiding this comment.
Tags здесь точно ни при чем, лучше search.
| hx-indicator=".htmx-indicator"> | ||
| </label> | ||
| </div> | ||
| <div id="active_search_results" class="mr-2" style="position: absolute; |
There was a problem hiding this comment.
Стили лучше не зашивать в элементы, а прописать в css-файл. Раз у нас уже используется css-каркас Bootstrap, то можно использовать инструменты оттуда — это чаще проще и красивее, чем изобретение своих. В частности сейчас элемент с результатами выглядит малопривлекательно.
| def get_results(request): | ||
| search_term, results = search_models( | ||
| request.POST.get('text', ''), search_in=( | ||
| Category, |
There was a problem hiding this comment.
Если будет много результатов, то это будет выглядеть так себе.
Тут нужно ограничить их максимальное число.
Ещё, может быть, поможет, если мы здесь исключим некоторые разделы, например, Персоны.
| <input class="form-control" autofocus type="search" aria-label="Search" name="text" placeholder="Поиск по справочнику" value="{{ search_term }}" required itemprop="query-input"> | ||
| <label for="tags"> | ||
| <input | ||
| id='tags' |
There was a problem hiding this comment.
В атрибутах используй везде двойные кавычки, чтобы не было разнобоя.
| Reference, | ||
| App, | ||
| )) | ||
| if len(results) > 5: |
There was a problem hiding this comment.
Сначала выбрать из БД все результаты, а потом их усечь — не очень удачное идея. Лучше вовсе не выбирать из БД лишнее.
|
|
||
| from .apps.realms import bootstrap_realms | ||
| from .apps.views import page_not_found, permission_denied, server_error, index, search, login, telebot, user_settings | ||
| from .apps.views.search import suggest |
There was a problem hiding this comment.
Этот импорт не используется и здесь не нужен.
| @@ -0,0 +1,5 @@ | ||
| {% for item in results %} | ||
| <div> | ||
| <a href="{{ item.get_absolute_url }}">{{ item.title }}</a> |
There was a problem hiding this comment.
Название может быть на столько длинное, что раздвинет блок с вариантами за края страницы.
| <form class="form-inline" action="/search/" method="post" itemprop="potentialAction" itemscope itemtype="https://schema.org/SearchAction"> | ||
| {% csrf_token %} | ||
| <div role="search" class="mr-2"> | ||
| <div id="search" role="search" class="mr-2"> |
There was a problem hiding this comment.
А для чего тут id? Он где-то используется?
No description provided.