Slow dropdown menu for foriegn key

I have created a backend website and is in production. It is using jawsdb and one of my models have 15000 records. The problem is when I click on the dropdown list of another model in admin panel it to select a model, it takes too much time for the list to appear and the search bar on the dropdown list hangs as well while writing. Is it because of cheap heroku plans and jawsdb. I could nt have messed up in the code.

Add the foreign key field with 15000 records to autocomplete_fields

class ModelWithLotsOfRecordsAdmin(admin.ModelAdmin):
    ordering = ['some_field']
    search_fields = ['some_field']

class ModelWithTheForeignKeyAdmin(admin.ModelAdmin):
    autocomplete_fields = ['foreign_key']

The dropdown will then not render all the options will load them asynchronously when searched

Back to Top