About Autocomplete Fields

Pages with Django frontend and administration forms load faster when relations to other models use autocomplete fields instead of the default select fields.

1
2
3
4
5
6
7
# events/admin.py
from django.contrib import admin
from .models import Event

@admin.register(Event)
class EventAdmin(admin.ModelAdmin):
    autocomplete_fields = ["venue", "organizers"]

Tips and Tricks Programming Optimization Performance Django 5.x Django 4.2 Django 3.2