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

Django 3.0 #927

Closed
sehmaschine opened this issue Jan 6, 2020 · 6 comments
Closed

Django 3.0 #927

sehmaschine opened this issue Jan 6, 2020 · 6 comments
Assignees

Comments

@sehmaschine
Copy link
Owner

No description provided.

@sehmaschine sehmaschine self-assigned this Jan 6, 2020
@sehmaschine
Copy link
Owner Author

see d1e697a

@StevenMapes
Copy link

StevenMapes commented Jan 14, 2020

Bug - TabularInlines do not clone the SELECT lists when using autocomplete_forms

Versions:

  • Django 3.0.2
  • Grappelli 2.14.1 installed via git+https://github.com/sehmaschine/django-grappelli.git@stable/2.14.x

The first element works but clicking "Add Another" does not retain the SELECT2 settings nor reinitialised the forms.

Example

class UserDBAccessInline(admin.TabularInline):
    model = UserDBAccess
    autocomplete_fields = ['user', 'db_name']
    can_delete = True
    extra = 1
    classes = ('grp-collapse grp-open',)
    inline_classes = ('grp-collapse grp-open',)

class UserAdmin(BaseUserAdmin):
    inlines = (UserDBAccessInline,)

admin.site.unregister(User)
admin.site.register(User, UserAdmin)

The SELECT list that is created looks like this

<select name="db_access-1-databases" id="id_db_access-1-databases" class="admin-autocomplete" data-ajax--cache="true" data-ajax--delay="250" data-ajax--type="GET" data-ajax--url="/maze/common/databases/autocomplete/" data-theme="admin-autocomplete" data-allow-clear="false" data-placeholder="">
</select>
```

Where as the original rendered element is
```
<select name="db_access-0-databases" id="id_db_access-0-databases" class="admin-autocomplete select2-hidden-accessible" data-ajax--cache="true" data-ajax--delay="250" data-ajax--type="GET" data-ajax--url="/maze/common/databases/autocomplete/" data-theme="admin-autocomplete" data-allow-clear="false" data-placeholder="" tabindex="-1" aria-hidden="true">
</select>

So the SELECT2 classes are not being copied.

I have removed Grappelli and re-tested using the native Django Admin templates and those work.

@StevenMapes
Copy link

StevenMapes commented Jan 14, 2020

Related. I find that if you use both StackedInline and TabularInline classes within the same django admin page then SELECT2 errors. Though I can see that it is loading in both the Grappelli and normal Django admin autocomplete JS and CSS files (even with caching disabled within the browser).

This results in both a JS warning and a JS error

jQuery.Deferred exception: $element.select2 is not a function TypeError: $element.select2 is not a function
    at init (http://127.0.0.1:8000/static/admin/js/autocomplete.js:14:18)
    at HTMLSelectElement.<anonymous> (http://127.0.0.1:8000/static/admin/js/autocomplete.js:21:13)
    at Function.each (http://127.0.0.1:8000/static/grappelli/jquery/jquery.min.js:2:2573)
    at e.fn.init.$.fn.djangoAdminSelect2 (http://127.0.0.1:8000/static/admin/js/autocomplete.js:19:11)
    at HTMLDocument.<anonymous> (http://127.0.0.1:8000/static/admin/js/autocomplete.js:29:60)
    at l (http://127.0.0.1:8000/static/grappelli/jquery/jquery.min.js:2:29375)
    at c (http://127.0.0.1:8000/static/grappelli/jquery/jquery.min.js:2:29677) undefined


jquery.min.js:2 Uncaught TypeError: $element.select2 is not a function
    at init (autocomplete.js:14)
    at HTMLSelectElement.<anonymous> (autocomplete.js:21)
    at Function.each (jquery.min.js:2)
    at e.fn.init.$.fn.djangoAdminSelect2 (autocomplete.js:19)
    at HTMLDocument.<anonymous> (autocomplete.js:29)
    at l (jquery.min.js:2)
    at c (jquery.min.js:2)

UPDATE 1 : On further testing this also happens when using just the StackedInline.

UPDATE 2: Having now had this error I can not even get the page to render the contents the first time around anymore. I have using local storage for testing, where the static files are collected two folders up. I have deleted all of the files from that folder and then re-run collect static but it is still including the original files including http://127.0.0.1:8000/static/admin/js/autocomplete.js which is no longer blank

UPDATE 3

I have grappelli as my first entry within INSTALLED_APPS as well as within the projects base urls.py but do still get clashes with these files though it should ignore the default Django ones over Grappelli as that one comes first.

Found another file with the destination path 'admin/js/urlify.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/prepopulate_init.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/SelectBox.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/prepopulate.min.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/collapse.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/change_form.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/calendar.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/actions.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/inlines.min.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/jquery.init.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/cancel.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/autocomplete.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/SelectFilter2.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/popup_response.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/prepopulate.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/actions.min.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/core.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/inlines.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/collapse.min.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/jquery/LICENSE.txt'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/jquery/jquery.min.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/jquery/jquery.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/xregexp/LICENSE.txt'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/xregexp/xregexp.min.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/xregexp/xregexp.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/LICENSE.md'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/select2.full.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/select2.full.min.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/km.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/fa.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/sr.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/et.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ka.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/sv.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/mk.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/he.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/dsb.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/pt.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/sk.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/fi.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ar.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/tk.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/sq.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/sl.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ms.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/es.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/az.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/hsb.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ne.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/en.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/af.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/is.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/bn.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ja.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ro.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/fr.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ca.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/zh-CN.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ko.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/hr.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/da.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/uk.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/pt-BR.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/pl.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/lv.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/lt.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/el.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/nb.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/bg.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/hy.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/gl.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/vi.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/sr-Cyrl.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/hi.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/hu.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/tr.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/it.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/de.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/bs.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/nl.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/id.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/th.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ru.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/ps.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/zh-TW.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/eu.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/vendor/select2/i18n/cs.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/admin/DateTimeShortcuts.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/js/admin/RelatedObjectLookups.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.

Update 4
I've now tested with the latest 2.12.x branch, the latest 2.13.x branch and the 2.14.1 and up until 2.14.1 the inlines initialise with the values but the are not copied across. I assume this is because it is using Django's SELECT2 logic. 2.14.1 now consistently renders empty select lists even on the first load, does not make any requests to the webserver for the autocomplete and show the SELECT2 js error mentioned in issue #908

@sehmaschine
Copy link
Owner Author

@StevenMapes thanks for the extensive testing. we'll take a look asap.

sehmaschine added a commit that referenced this issue Feb 10, 2020
@sehmaschine
Copy link
Owner Author

I've added a fix to stable/2.14.x which works with my setup. Please let me know if this also fixes your issue – if so, I'll do a release.

@StevenMapes
Copy link

I can confirm that the issues I was seeing with both TabularInline and StackedInline are both now working with Django 3.0.3 using the latest 2.14.x branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants