I use Django.
My admin.py:
class CardInlineAdmin(admin.StackedInline):
model = Card
autocomplete_fields = ['project', 'course', 'vacancy', 'news', ]
@admin.register(Section)
class SectionAdmin(admin.ModelAdmin):
list_display = ('name', 'id', 'priority', 'is_active',)
inlines = (CardInlineAdmin,)
search_fields = ['project', 'course', 'vacancy', 'news']
class Media:
js = (
'//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
'js/card_in_section.js',
)
If I open SectionAdmin on admin page the file card_in_section.js will not work.
If I remove autocomplete_fields from CardInlineAdmin the file card_in_section.js will work.
What is the reason of such behavior?
I solved my problem)
I checked
Networkon admin page and understood that for some reason my filecard_in_section.jsloaded beforeautocomplete.js.So, I tried to add
autocomplete.jsto class Media beforecard_in_section.jsand it solved my problem.