* cc: David Sanders, Marcelo Galigniana (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => (none)
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:7>
Comment (by David Sanders):
Replying to [ticket:34789 devin13cox]:
> My initial guess is that updating the query to not include the "Chosen"
column in filter_horizontal fields would solve this issue (something like
> {{{
> const selectsRelated = document.querySelectorAll(`[data-model-
ref="${modelName}"] div:not(.selector-chosen) > select:not(.admin-
autocomplete)`);
> }}}
That could work 👍 I'm just wondering though whether there's a better
approach than to continuously blacklist ancestors as we come across these
🤔
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:8>
Comment (by yokeshwaran1):
Hi David,
Im new to this repo, so I appreciate any guidance or feedback u can
offer.
Regardin issue with filter_horizontal "Chosen" column. From the
discussion, I think about a solution which will not continuously
blacklisting ancestors
1. Adding a data attribute like data-context to select elements during its
render phase in the Django admin templates. So each select will have a
more specific context about its purpose (eg. source, target, chosen etc.).
2. Then modifying the query in RelatedObjectLookups.js to use this new
data-context attribute, so our selector will become:
{{{
const selectsRelated = document.querySelectorAll(`[data-model-
ref="${modelName}"][data-context="source"] select:not(.admin-
autocomplete)`);
}}}
This approach will provide clear context for each select element which
makes JavaScript logic more intentional. would this be a feasible,
acceptable solution in ur opinion? I'm eager to hear ur thoughts & make
any necessary adjustments. Once approach is approved, I'm interested in
working on this ticket. Please let me know if that's possible.
Replying to [comment:8 David Sanders]:
> Replying to [ticket:34789 devin13cox]:
> > My initial guess is that updating the query to not include the
"Chosen" column in filter_horizontal fields would solve this issue
(something like
> > {{{
> > const selectsRelated = document.querySelectorAll(`[data-model-
ref="${modelName}"] div:not(.selector-chosen) > select:not(.admin-
autocomplete)`);
> > }}}
>
> That could work 👍 I'm just wondering though whether there's a better
approach than to continuously blacklist ancestors as we come across these
🤔
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:9>
Comment (by David Sanders):
Replying to [comment:9 yokeshwaran1]:
> I think about a solution which will not continuously blacklisting
ancestors
Yep that's along the lines of what I was getting at 😊👍
The question is though which approach is clearer/easier to maintain. The
benefit of whitelisting is we can remove `not(.admin-autocomplete)` too I
think 🤔
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:10>
Comment (by yokeshwaran1):
Thanks, David. I’ll make the necessary changes and submit a PR with tests
soon.
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:11>
Comment (by yokeshwaran1):
Hi David,
I have opened a PR to address this issue:
https://github.com/django/django/pull/17219
Replying to [comment:11 yokeshwaran1]:
> Thanks, David. I’ll make the necessary changes and submit a PR with
tests soon.
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:12>
* has_patch: 0 => 1
Comment:
Setting the has patch flag.
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:13>
* owner: (none) => yokeshwaran1
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:14>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34789#comment:15>