Clone wiki

django-autocomplete / Usage0.X

Usage Example

for a more detailed example, see the demo application.

from django.contrib.auth.models import User
from autocomplete import autocomplete

autocomplete.register('user', User.objects.all(), ('username', 'email'), 5)

urlpatterns = patterns('',
    url('^autocomplete/(\w+)/$', autocomplete, name='autocomplete'),
    # other patterns

from django import forms
from django.contrib.auth.models import Message
from autocomplete import ModelChoiceField

class InsertMessage(forms.ModelForm):
    class Meta:
        model = Message

    user = ModelChoiceField('user')

You can use AutoCompleteField/Widget even on the admin site.