Answer the question
In order to leave comments, you need to log in
How to configure django_autocomplete_light to work with GenericForeignKey?
So the essence of the problem, there is a model Foo
class Foo(Displayable):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
class Bar(models.Model):
name = models.CharField(max_length=255)
slug = models.SlugField(max_length=255)
import autocomplete_light
from barapp.models import Bar
class AutocompleteBarItems(autocomplete_light.AutocompleteGenericBase):
choices = (
Bar.objects.all(),
)
search_fields = (
('name', ),
)
autocomplete_light.register(AutocompleteModelItems)
class EntryAdmin(admin.ModelAdmin):
form = autocomplete_light.modelform_factory(Entry)
KeyError: u'manager'instead of a working autocomplete.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question