Ive been searching google for hours but haven't been able to find anything. Im rather new to Django and was wondering how to accomplish the following
Im looking to implement a search on a page to filter records that are returned by a query Similar to how eBay do. (see link down left hand side)
Link to eBay to show desired search functionality
Could some one me in the right direction or tell me what need to look into to implement such a feature.
use get_search_results
(new in django 1.6)
class PersonAdmin(admin.ModelAdmin):
list_display = ('name', 'age')
search_fields = ('name',)
def get_search_results(self, request, queryset, search_term):
queryset, use_distinct = super(PersonAdmin, self).get_search_results(request, queryset, search_term)
try:
search_term_as_int = int(search_term)
queryset |= self.model.objects.filter(age=search_term_as_int)
except:
pass
return queryset, use_distinct
search_term
is what you input, and query_set
is the result,you need to change query_set
Ive been searching google for hours but haven't been able to find anything. Im rather new to Django and was wondering how to accomplish the following
Im looking to implement a search on a page to filter records that are returned by a query Similar to how eBay do. (see link down left hand side)
Link to eBay to show desired search functionality
Could some one me in the right direction or tell me what need to look into to implement such a feature.
use get_search_results
(new in django 1.6)
class PersonAdmin(admin.ModelAdmin):
list_display = ('name', 'age')
search_fields = ('name',)
def get_search_results(self, request, queryset, search_term):
queryset, use_distinct = super(PersonAdmin, self).get_search_results(request, queryset, search_term)
try:
search_term_as_int = int(search_term)
queryset |= self.model.objects.filter(age=search_term_as_int)
except:
pass
return queryset, use_distinct
search_term
is what you input, and query_set
is the result,you need to change query_set
0 commentaires:
Enregistrer un commentaire