Override a form in Django admin
You can override forms for django's built-in admin by setting form attribute of ModelAdmin to your own form class. See:
- https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form
- https://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin
It's also possible to override form template - have a look at https://docs.djangoproject.com/en/dev/ref/contrib/admin/#custom-template-options
If you're looking specifically for autocomplete I can recommend https://github.com/crucialfelix/django-ajax-selects
How to override a form in the django admin according to the docs:
from django import forms
from django.contrib import admin
from myapp.models import Person
class PersonForm(forms.ModelForm):
class Meta:
model = Person
exclude = ['name']
class PersonAdmin(admin.ModelAdmin):
exclude = ['age']
form = PersonForm