Hi Hurlu,

I can suggest two approaches here.

   1. change your model so that it contains two fields: 'allowed' and 
   'disallowed'. Every of which is an array of allowed and disallowed items 
   respectively. You can use JSON Field for that. This approach has benefit 
   that your models looks simple and can be easily extended with additional 
   allowed/disallowed items. In your example every time new valuable property 
   identified your should extend model and handle migrations both schema and 
   data. With this approach Django/admin can handle your 
   requirements pretty straightforward.
   2.  create custom form with 2 custom fields: allowed and disallowed. 
   Exclude all extra filters as an 'excluded'. And override 'save' method to 
   map users data from use input to model filters. And do it before model is 
   saved.

I hope that should solve your problem.
Regards

On Monday, July 25, 2016 at 6:25:29 PM UTC+3, Hurlu wrote:
>
> Hi everyone,
>
> For the project I'm working on, I got a Dish Model in which, in order to 
> filter different dishes for allergens or other reasons, I got a 
> BooleanField to check if the dish is* pork-free*, another to check if it's* 
> nuts-free* and a good other 
>
> *dozen.*As you would expect, displaying all thoses filters side by side 
> would by very unesthetical and unpratical. So I aimed to reduce their 
> number to two: One *multiple select* filter for "*contains this:*", and 
> another for "*does not contain*:".
>
> My researches so far were not very successful : the best I could find is 
> this module , namely Django-adminfilters 
> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fsaxix%2Fdjango-adminfilters&sa=D&sntz=1&usg=AFQjCNGfI8f40pGxxTGp76ZR6elji8A_Lw>,
>  
> that I could not quite get to work, as well as many not-so-helpful SO 
> posts. 
> <http://stackoverflow.com/questions/7834990/selecting-multiples-choices-in-django-admin-filter-list-filter>
> <https://github.com/saxix/django-adminfilters>
> Could someone please enlighten me, be it with a way to do it or a 
> workaround ?
> Thanks a lot !
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9184f12b-1d1d-4630-9f5a-a2ab74980726%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to