oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
425 stars 82 forks source link

Search feature #28

Closed luisza closed 7 years ago

luisza commented 7 years ago

As django admin does search_fields are available, and you can filter using doble underscore (__) to search across objects.

split_space_search split search text in parts using the string provided, this can be usefull to have better results but have impact in search performance, if split_space_search is True then ' ' is used

    class Myclass(CRUDView):
        model = Customer
        search_fields = ['description__icontains']
        split_space_search = ' ' # default False 

NOTE: icontains is not set by default as django admin does, so you need to set if not equal search is wanted

oscarmlage commented 7 years ago

I've fixed a couple of things in dfa74ce94bb59634acdaebaa9d8a980aab8d988e. @luisza please take a look to see if it's ok with you.