mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-21 04:51:19 -05:00
Add autocomplete functionality for parks: implement URLs, views, and templates for real-time suggestions
This commit is contained in:
15
parks/autocomplete.py
Normal file
15
parks/autocomplete.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from autocomplete import ModelAutocomplete
|
||||
from .models import Park
|
||||
|
||||
|
||||
class ParkAutocomplete(ModelAutocomplete):
|
||||
"""Autocomplete class for Park model."""
|
||||
model = Park
|
||||
search_attrs = ['name', 'city', 'state', 'country'] # Fields to search
|
||||
minimum_search_length = 2 # Start searching after 2 characters
|
||||
max_results = 8 # Limit to 8 suggestions
|
||||
|
||||
# Customize display text
|
||||
no_result_text = "No parks found matching your search."
|
||||
narrow_search_text = "Showing %(page_size)s of %(total)s parks. Try narrowing your search."
|
||||
type_at_least_n_characters = "Type at least %(n)s characters to search parks"
|
||||
Reference in New Issue
Block a user