mrts / django-admin-list-filter-dropdown

Use dropdowns in Django admin list filter
MIT License
315 stars 48 forks source link

RelatedSelect2DropdownFilter #8

Closed macolo closed 4 years ago

mrts commented 6 years ago

Great work! Many thanks for your contribution 🙂 ! I'm compelled to just press the green Merge button - but I would like to ponder over this a bit more, investigate if it's possible to simplify and test.

macolo commented 6 years ago

Hi @mrts thanks! You are right the solution is not ready for integration in a module yet. Specifically its still unclear how to get the query type parameter ('_exact', 'gte', 'lte', etc) in the template. Its currently hard-coded.

mrsarm commented 6 years ago

Just mention this is for #7 to be linked properly.

When this will merged? I think it would be a great improvement.

mrts commented 6 years ago

@mrsarm Do you have time to review this (carefully, meticulously, deliberately :))?

mrsarm commented 6 years ago

@macolo checking the changes in the README file, why should we add CSS and JS dependencies to the ModelAdmin class?

If you are using the same Selecte2 component built-in with Dango 2, we shouldn't add any extra-dependency like if we have Django<2.0. Right?

mrsarm commented 6 years ago

Didn't work with Django 2.0.7.

I installed the dependency in my virtual env with Python 3.6:

pip install --upgrade -e git://github.com/what-digital/django-admin-list-filter-dropdown.git@c5c715ffa87e281f8a28863790970a9709d332ca#egg=django-admin-list-filter-dropdown

Then added to my ModelAdmin:

    js = (
        'admin/js/vendor/jquery/jquery.min.js',
        'admin/js/vendor/select2/select2.full.min.js',
        'admin/js/jquery.init.js',
        'django_admin_listfilter_dropdown/autocomplete.js',
    )

    css = {
        'screen': (
            'admin/css/vendor/select2/select2.min.css',
            'admin/css/autocomplete.css',
        ),
    }

And the fields defined with:

    search_fields = ('id', 'title', 'item__item_description',
                     'user', 'user__first_name', 'user__last_name')
    list_filter = (
        ('user', RelatedSelect2DropdownFilter),

But I see this:

screenshot from 2018-07-31 13-05-15

Also the dropdown in the screenshot doesn't have any option other than "All". I don't see any error logged in the Python console or the browser console neither.

mrts commented 6 years ago

Thanks a lot for testing! Let's wait for @macolo's comments

macolo commented 5 years ago

@mrts have you done all the steps in https://github.com/mrts/django-admin-list-filter-dropdown/pull/8/files#diff-04c6e90faac2675aa89e2176d2eec7d8 ?

mrts commented 5 years ago

@mrsarm , I think @macolo 's question was addressed to you - have you done all the steps in https://github.com/mrts/django-admin-list-filter-dropdown/pull/8/files#diff-04c6e90faac2675aa89e2176d2eec7d8 ?

mrsarm commented 5 years ago

Hey @macolo , what steps do you think are missed from the steps in mentioned here https://github.com/mrts/django-admin-list-filter-dropdown/pull/8#issuecomment-409276561 ?

macolo commented 5 years ago

@mrsarm looking at your feedback I am not sure whether you added the app before django admin in INSTALLED_APPS

mrsarm commented 5 years ago

@macolo oh yes, I didn't mention that because i already had the plugin configured in my project (the latest stable version), here are my installed apps:

INSTALLED_APPS = [
    'mtasks.apps.MtasksConfig',
    'advanced_filters',
    'admin_view_permission',
    'django_admin_listfilter_dropdown',
    'adminfilters',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
macolo commented 5 years ago

I'll have a look at this with a new django test setup to see whether I can reproduce the troubles.

macolo commented 4 years ago

closed in favour of https://github.com/farhan0581/django-admin-autocomplete-filter