django-autocomplete-light demo

The test_project lives in the test_project subdirectory of django-autocomplete-light’s repository.

Install

We’re going to use virtualenv, so that we don’t pollute your system when installing dependencies. If you don’t already have virtualenv, you can install it either via your package manager, either via python’s package manager with something like:

sudo easy_install virtualenv

Install last release:

rm -rf django-autocomplete-light autocomplete_light_env/

virtualenv autocomplete_light_env
source autocomplete_light_env/bin/activate
git clone https://jpic@github.com/yourlabs/django-autocomplete-light.git
cd django-autocomplete-light/test_project
pip install -r requirements.txt
./manage.py runserver

Install development versions, if you want to contribute hehehe:

AUTOCOMPLETE_LIGHT_VERSION="master"
CITIES_LIGHT_VERSION="master"

rm -rf autocomplete_light_env/

virtualenv autocomplete_light_env
source autocomplete_light_env/bin/activate
pip install -e git+git://github.com/yourlabs/django-cities-light.git@$CITIES_LIGHT_VERSION#egg=cities_light
pip install -e git+git://github.com/yourlabs/django-autocomplete-light.git@$AUTOCOMPLETE_LIGHT_VERSION#egg=autocomplete_light
cd autocomplete_light_env/src/autocomplete-light/test_project
pip install -r requirements.txt
./manage.py runserver

Login with user “test” and password “test”.

If you want to redo the database, but make sure you read README first:

rm db.sqlite
./manage.py syncdb
./manage.py cities_light

Try basic features

Once you have the test_project server running (see INSTALL if you don’t), open the first contact.

You will see two addresses:

  • one at Paris, France
  • one at Paris, United States

The reason for that is that there are several cities in the world with the name “Paris”. This is the reason why the double autocomplete widget is interresting: it filters the cities based on the selected country.

Note that only cities from France, USA and Belgium are in the demo database.

Note that you can test autocompletes for generic foreign keys in this project too.

Try advanced features

This project demonstrates how the autocomplete can suggest results from a remote API - and thus which don’t have a pk in the local database.

In one console:

cd test_project
./manage.py runserver

In another:

cd test_api_project
./manage.py runserver 127.0.0.1:8001

If you’re not going to use localhost:8000 for test_project, then you should update source urls in test_api_project/test_api_project/autocomplete_light_registry.py.

Now, note that there are no or few countries in test_api_project database.

Again, test_project’s database only includes countries France, Belgium and America so there’s no need to try the other one unless you know what you’re doing.

Also note that, city and country autocomplete work the same. The reason for that is that test_api_project uses City and Country remote channel to add results to the autocomplete that are not in the local database.

Project Versions

Table Of Contents

Previous topic

Welcome to django-autocomplete-light’s documentation!

Next topic

Quick start

This Page