Hi

I am trying to get django-autocomplete-light (
https://github.com/yourlabs/django-autocomplete-light) working for my
project in the admin.  I have the following files and code, running with
Django 1.4.3.  In the edit form for the Company, the drop-down list for
country has been replaced by an empty edit box, but beyond that there is no
list displaying when I start typing...

I'd appreciate any ideas as to how to get this basic example working.

Thanks
Derek


# models.py

class Country(Model):
    id = AutoField(primary_key=True)
    code = CharField(unique=True, max_length=5)
    name = CharField(unique=True, max_length=250)

class Company(Model):
    id = AutoField(primary_key=True)
    name = CharField(max_length=250)
    country = ForeignKey(Country)

# autocomplete_light_registry.py

import autocomplete_light
from models import Country

class CountryAutocomplete(autocomplete_light.AutocompleteModelBase):
    search_fields = ['^name', ]

autocomplete_light.register(Country, CountryAutocomplete)

# admin.py

import autocomplete_light
import autocomplete_light_registry

class CompanyForm(forms.ModelForm):
    country = forms.ModelChoiceField(
        Country.objects.all(),
        widget=autocomplete_light.ChoiceWidget('CountryAutocomplete'))

    class Meta:
        model = Company

class CompanyAdmin(admin.ModelAdmin):
    list_display = ('name', 'country', )
    list_filter = ('country', )
    form = CompanyForm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to