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

Filters #29

Closed oscarmlage closed 6 years ago

oscarmlage commented 7 years ago

Django Admin has filters for the listings, something like:

    list_filter = ('provider', 'date', 'paid', 'registered')
    list_filter = (('date', DateRangeFilter),
                   ('customer', admin.RelatedOnlyFieldListFilter),)

is converted in something like:

image

I've not thought about how it could be done in a simple way, maybe something similar to widgets:

  1. Declare the filter field and type, i.e.: ('date', DateFilter),('customer', RelatedFilter) ('status', BoolFilter)...
  2. Define the action for every kind of filter: date <= request.input, customer.pk=request.input, status = True/False...
  3. Define how to paint the widget of every filter (date selector, just a link, dropdown select...)

Brainstorming mode is open :)

luisza commented 7 years ago

Sound good, I did something similar in other project for django admin view, maybe this could help https://github.com/luisza/django-cruds-adminlte/blob/filter/cruds_adminlte/filter.py mode of use:

# do a form ticketForm
class ticketFilter(FormFilter):
    template = "filter_template.html"
    title = "ticket filter title"
    form = ticketForm
    form_instance = None
    remove_params = ['filtro', 'field_text', 'otherautocompletefield_text']
    map_parameters = {'cicle': 'acrrosmodelworks__ciclo',
                      'othermapfield': 'other model field'}

I have no time this week to implement it, but as summary with this you can put whatever form you want to filter, also forms than has autocomplete (django-ajaxselect).

One think more it's also important include a preserver filter feature so search and filter could work in the same view.

Other thing. Django admin filter thieft a lot of space show filter, maybe we can put some vertical colapse to show or hide filter

luisza commented 7 years ago

PR #40 help to solve this :), maybe a look revision needed.

oscarmlage commented 7 years ago

I'm off for vacations these days but definitely I'm looking forward to have time to review the PR. Thanks for the work @luisza

luisza commented 6 years ago

This issue was reviewed ? If not maybe the filter functionality solve this issue and could be close

oscarmlage commented 6 years ago

4538715 Adds the filters as feature. Thanks @luisza for the effort.