Skip to content

incuna/django-autocomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

===================
Django autocomplete
===================

Provides autocomplete widgets.

To Use:

Add autocomplete to you INSTALLED_APPS. 

Add the autocomplete.urls to your urls.
e.g.

    urlpatterns += patterns(
        (r'^autocomplete/', include('autocomplete.urls')),
    )

Use the autocomplete widgets in your forms

    from autocomplete.widgets import AutocompleteSelectMultiple

    class Topping(models.Model):
        name = forms.CharField(max_length=250, required=True)

    class PizzaForm(forms.ModelForm):
        toppings = forms.ModelMultipleChoiceField(Topping, widget=AutocompleteSelectMultiple(Topping, search_fields=['name']), )

To get it working in the templates, you need to include the media, for example:

    {% block extra_head %}
        {{ form.media }}
    {% endblock %}