Django Ajax Selects
Here's what I did, to no avail:
Added ajax_select
to my INSTALLED_APPS
in settings.py
Added (r'ajax_select', include('ajax_select.urls')),
to urls.py
Added this to settings.py
:
AJAX_LOOKUP_CHANNELS = {
'postal_code': {'model': 'places.PostalCode', 'search_field': 'code'}
}
Added this to admin.py
:
class AddressAdmin(admin.ModelAdmin):
form = make_ajax_form(Address, {'postal_code':'postal_code'})
admin.site.register(Address, AddressAdmin)
When I tried viewing the relevant page in the admin site and typed in the text box nothing came up. Looking in Firebug, nothing seems to be happening. Presumably because no JS is included; I guess the form/widgets don't include any the way the other admin widgets do.
So, I tried including the media the only way I know how:
class AddressForm(forms.ModelForm):
postal_code = AutoCompleteSelectField('postal_code')
class Media:
css = {
'all': ['media/css/ui-lightness/jquery-ui-1.8.9.custom.css', 'media/css/iconic.css']
}
js = ['media/js/jquery-1.4.4.min.js', 'media/js/jquery-ui-1.8.9.custom.min.js', 'media/js/ajax_select.js']
class AddressAdmin(admin.ModelAdmin):
form = AddressForm
admin.site.register(Address, AddressAdmin)
Now everything gets included, but it still doesn't work. Nothing seems to be happening.
Did I miss a step? Why aren't any JS events firing?