mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 06:11:07 -05:00
2.6 KiB
2.6 KiB
Park Search Integration
Overview
Integrated the parks app with the site-wide search system to provide consistent filtering and search capabilities across the platform.
Implementation Details
1. Filter Configuration
# parks/filters.py
ParkFilter = create_model_filter(
model=Park,
search_fields=['name', 'description', 'location__city', 'location__state', 'location__country'],
mixins=[LocationFilterMixin, RatingFilterMixin, DateRangeFilterMixin],
additional_filters={
'status': {
'field_class': 'django_filters.ChoiceFilter',
'field_kwargs': {'choices': Park._meta.get_field('status').choices}
},
'opening_date': {
'field_class': 'django_filters.DateFromToRangeFilter',
},
'owner': {
'field_class': 'django_filters.ModelChoiceFilter',
'field_kwargs': {'queryset': 'companies.Company.objects.all()'}
},
'min_rides': {
'field_class': 'django_filters.NumberFilter',
'field_kwargs': {'field_name': 'ride_count', 'lookup_expr': 'gte'}
},
'min_coasters': {
'field_class': 'django_filters.NumberFilter',
'field_kwargs': {'field_name': 'coaster_count', 'lookup_expr': 'gte'}
},
'min_size': {
'field_class': 'django_filters.NumberFilter',
'field_kwargs': {'field_name': 'size_acres', 'lookup_expr': 'gte'}
}
}
)
2. View Integration
- Updated
ParkListViewto useHTMXFilterableMixin - Configured proper queryset optimization with
select_relatedandprefetch_related - Added pagination support
- Maintained ride count annotations
3. Template Structure
- Created
search/templates/search/partials/park_results.htmlfor consistent result display - Includes:
- Park image thumbnails
- Basic park information
- Location details
- Status indicators
- Ride count badges
- Rating display
4. Quick Search Support
- Modified
search_parksview for dropdown/quick search scenarios - Uses the same filter system but with simplified output
- Limited to 10 results for performance
- Added location preloading
Benefits
- Consistent filtering across the platform
- Enhanced search capabilities with location and rating filters
- Improved performance through proper query optimization
- Better maintainability using the site-wide search system
- HTMX-powered dynamic updates
Technical Notes
- Uses django-filter backend
- Integrates with location and rating mixins
- Supports both full search and quick search use cases
- Maintains existing functionality while improving code organization