Skip to content
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

🐛 Issues with django admin inline #297

Closed
sahilasopa opened this issue Aug 27, 2024 · 2 comments · Fixed by #300
Closed

🐛 Issues with django admin inline #297

sahilasopa opened this issue Aug 27, 2024 · 2 comments · Fixed by #300
Assignees
Labels
bug Something isn't working

Comments

@sahilasopa
Copy link

Bug Description

There has been this long and everlasting problem of using Django admin inline with a select2 widget, hours of browsing through stack-overflow and Github issues led me to nowhere.

The bug is:
Select2 Dropdown does not work when you add new inlines (works perfectly for existing inlines), I specifically faced this bug in Django admin

Steps to Reproduce

  1. Use a select2 widget on Django admin (link the admin via model form)
    the widget I used was HeavySelect2Widget
  2. click on add inline
  3. try to click on the dropdown widget and see NOTHING HAPPEN

Expected Behavior

It's expected to see a dropdown

@sahilasopa sahilasopa added the bug Something isn't working label Aug 27, 2024
@sahilasopa
Copy link
Author

the issue has been mentioned in #249 too

@mardukbp
Copy link

@sahilasopa I just submitted a PR that fixes this issue using the solution from #249 plus a small contribution of mine. Hopefully it will be merged soon. In the meantime you can try it yourself using the standard Django mechanism for overriding static files or templates.

@codingjoe codingjoe linked a pull request Sep 18, 2024 that will close this issue
codingjoe added a commit that referenced this issue Dec 10, 2024
As described in #249 and #297 django-select2 does not currently work
with selects added dynamically in the Django admin.

The solution was implemented in #249 and all credit should go to Jurrian
Tromp. I only added a small correction:

```diff
- jqRow.find('.select2-container').remove()
+ jqRow.find('.django-select2').parent().find('.select2-container').remove()
```

to only remove `.select2-container` when it is a sibling of
`.django-select2`. Otherwise the wrong `.select2-container` might get
deleted.

---------

Co-authored-by: Johannes Maron <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants