New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change_list_filter_confirm peoduces wrong url parameters #1007
Comments
What kind of filter is that? That’s not part of our package, right?
…On Mon 28. Nov 2022 at 00:36, Yuri Pimenov ***@***.***> wrote:
class TariffAdmin(admin.ModelAdmin):
change_list_template = "admin/change_list_filter_confirm.html"
list_filter = (
'merchant', # ('merchant', filters.GrappelliAutocompleteFilter),
'contract__legal'
)
Selecting merchant and contract__legal in this example multiple times (and
after that pressing Apply) produces an url like:
http://127.0.0.1:8000/admin/backend/tariff/?contract__legal__legal_id__exact=1&contract__legal__legal_id__exact=1&merchant__merchant_id__exact=2&contract__legal__legal_id__exact=1&merchant__merchant_id__exact=3
While select inputs allow only single choise.
—
Reply to this email directly, view it on GitHub
<#1007>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABNIWCUUT2SV5CUACQ43ETWKPWBLANCNFSM6AAAAAASMYLW7E>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
No, this filter is taken from docs. https://django-grappelli.readthedocs.io/en/latest/customization.html#changelist-filters |
I don't mean the template ... I'm talking about |
Well, GrappelliAutocompleteFilter is commented, I will update ticket text |
Yes, the issue persists on this minimal example.
where
Applying filter multiple times produces url like this: |
I see, thank for clarifying. We'll take a look asap. If you're in a hurry, feel free to submit a PR. |
By digging into source I found out that in filter.html
field_name appears to be empty and admin_list_filter() registered by @register.simple_tag is not called. Django's version appears to be called instead. I'm running Django 3.2 and followed all the steps of installation in grappeli documentation. Does that mean that tag search order is different since some versions of django? How do I force it to use grapelli's version? |
The issue appears to be more complex and I'm still curious why on Earth django doesnt look up grappeli's template tags, but it also appears that Grapelli's filters do not properly handle related fields. By default it is not a problem, the page immidiately refresh once you choose an option from select box. But if you have filters that require confirmation ("Apply" button) and your filters configured to look in relations like so:
then it incorrectly "glues" together selected items to be used for window.location later. Here's the patch to fix this problem.
without it keys like "merchant__merchant_id__exact" reduced to just "merchant" while "merchant__merchant_id" would be more correct. If you wish I can create a PR later. |
I think the only change needed in order to resolve this is to move
At least with my setup, this seems to work. Can you please check that? |
Ok, this might fix the lookup of admin_list_filter, gonna try it tonight. |
Selecting merchant and contract__legal in this example multiple times (and after that pressing Apply) produces an url like:
http://127.0.0.1:8000/admin/backend/tariff/?contract__legal__legal_id__exact=1&contract__legal__legal_id__exact=1&merchant__merchant_id__exact=2&contract__legal__legal_id__exact=1&merchant__merchant_id__exact=3
While select inputs allow only single choise.
The text was updated successfully, but these errors were encountered: