Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
What is the connection between autocomplete_fields and JS in Media class?

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I solved my problem)
I checked Network on admin page and understood that for some reason my file card_in_section.js loaded before autocomplete.js.
So, I tried to add autocomplete.js to class Media before card_in_section.js and it solved my problem.

class Media:
        js = (
            '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
            'admin/js/autocomplete.js',
            'js/card_in_section.js',
        )
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!