id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 14370,Adding support for Autocomplete in contrib.admin,Germano Gabbianelli,Johannes Maron,"I've tried to implement Autocomplete for contrib.admin using jQuery UI Autocomplete.[[BR]] Here's the code: http://bitbucket.org/tyrion/django [[BR]] Here's a live demo: http://djangoac.tyrion.mx/admin/ (login with test/test). (It supports both ForeignKey and ManyToMany). I don't know if I should attach the complete patch here. It's kinda big (I included jquery-ui), however you can see it online at http://bitbucket.org/tyrion/django/changeset/04488ec05e92 ). Now it's implemented using an ""autocomplete_fields"" attribute which is a dict (field:related_fields): {{{ #!python class MyModelAdmin(admin.ModelAdmin): autocomplete_fields = {'user': ('username', 'email')} }}} But because I've been asked: {{{ tyrion-mx: what about making the autocomplete_fields a dict of dicts, to be able to specify additional options for the autocompletion, e.g. number of search results or a custom label function? }}} I've written this patch (for my code) http://dpaste.com/hold/251220/ that let's you control the ""value"" (what is displayed in the input), ""label"" (what is displayed in the dropdown) and ""limit"" (max number of results) properties. With it a modeladmin could look something like this: {{{ #!python class DummyAdmin(admin.ModelAdmin): autocomplete_fields = dict( user1 = dict( fields = ('username', 'email'), value = 'username', limit = 10, ), friends = dict( fields = ('username', 'email'), label = u'%(first_name)s %(last_name)s', value = 'email', ), ) }}} In that case ""value"" and ""label"" can be either a function, a fieldname or a string like `u'%(username)s ""%(email)s""'`. ",New feature,closed,contrib.admin,dev,Normal,fixed,"autocomplete, jquery, javascript, widgets, admin",Yeago Germano Gabbianelli sehmaschine@… istruble thomas.schwaerzl@… thijs.triemstra@… hv@… 4glitch@… cmawebsite@… ramezashraf@… info@… James Pic zachborboa@… tymoteusz.jankowski@… tymoteusz.jankowski@… Kevin Brown,Accepted,1,0,0,0,0,1