Welcome to django-autocomplete-light’s documentation!¶
django-autocomplete-light’s purpose is to enable autocompletes quickly and properly in a django project: it is the fruit of years of R&D. It was designed for Django so that every part overridable or reusable independently. It is stable, tested, documented and fully supported: it tries to be a good neighbour in Django ecosystem.
- charfield, foreign key, many to many autocomplete widgets,
- generic foreign key, generic many to many autocomplete widgets,
- django template engine support for autocompletes, enabling you to include images etc ...
- add-another popup supported outside the admin too.
- keyboard is supported with enter, tab and arrows by default.
- Django 1.7, Python3 support
Each feature has a live example and is fully documented. It is also designed and documented so that you create your own awesome features too.
Upgrade from 1.x.x¶
To upgrade to v2, please enjoy the v1 to v2 upgrade instructions (documented with love !).
- the Autocomplete class design hasn’t changed at all.
data-*options the same,
- the django/form python code has been re-organised ie.
get_widgets_dict()is gone and
autocomplete_light.ModelFormwraps around all features by default.
autocomplete_light.GenericModelForm- generic foreign keys and django-generic-m2m are supported by default if installed.
You can run test projects for a local demo in a temporary virtualenv.
Click on any instruction step for details.
- Install the
django-autocomplete-light>=2.0.0prepackage with pip
- If using Django < 1.7, call
- Ensure you understand
autocomplete_light/static.htmlafter loading jquery.js (>=1.7)
- Optionally include it in
If you didn’t click any, and this is your first install: bravo !
v1 to v2¶
- Upgrading from django-autocomplete-light v1 to v2
- You should not use widget directly anymore
- Specification of the Autocomplete class to use
- Python class re-organisation
- Deprecation of
max-valueswas renamed to
data-autocomplete-placeholderis gone in favor of HTML5
- Widget template changes
- Script changes
pip install -U django-autocomplete-light. Check the CHANGELOG
for BC (Backward Compatibility) breaks. There should be none for minor
version upgrades ie. from 1.1.3 to 1.1.22, but there might be some
minor BC breaks for middle upgrades ie. 1.2.0 to 1.3.0.
Enabling autocompletes inside and outside of the admin has become piece of cake.
If you need anything more than just enabling autocompletes in the admin, then you should understand django-autocomplete-light’s architecture. Because you can override any part of it.
The architecture is based on 3 main parts which you can override to build insanely creative features as many users already did.
- Autocomplete classes
- Design documentation
- Form, fields and widgets
- Design documentation
- Voodoo black magic
Using just the concepts you’ve learned in the reference, here are some of the things you can do.
- Can’t see admin add-another
+button when overriding a
- RemovedInDjango18Warning: Creating a ModelForm without either the ‘fields’ attribute or the ‘exclude’ attribute is deprecated - form YourForm needs updating
- How to run tests
- Why not use Widget.Media ?
- Model field’s
verbose_nameare lost when overriding the widget
- Fields bound on values which are not in the queryset anymore raise a ValidationError
- How to override a JS method ?
- How to work around Django bug #9321: Hold down “Control” ... ?
- How to report a bug effectively ?
- How to ask for help ?