3

I'm trying to replace a SelectMultiple default widget by the ajax_select one.

I followed the installation guide, here are my files:

settings.py

AJAX_LOOKUP_CHANNELS = {
    'dubberword' : dict(model='content.DubberWord', search_field='name'),
}

INSTALLED_APPS = (
# ...
    'ajax_select',
# ...
)

urls.py

urlpatterns = patterns('',
# ...
  (r'^ajax_select/', include('ajax_select.urls')),
# ...
)

models.py

class DubberWord(models.Model):
  name = models.CharField(max_length=50, unique=True)
  image = models.ImageField(upload_to='images/', blank=True, null=True)

  def __unicode__(self):
    return self.name

class Dubber(models.Model):
  name = models.CharField(max_length=50)
  words = models.ManyToManyField(DubberWord, verbose_name='Items')

  def __unicode__(self):
    return self.name

admin.py

from ajax_select import make_ajax_form

class DubberAdmin(admin.ModelAdmin):
    form = make_ajax_form(Dubber, dict(words='dubberword'))

admin.site.register(Dubber,DubberAdmin)

And trying to load the admin page for a Dubber object, I get this message

Caught TemplateDoesNotExist while rendering: autocompleteselectmultiple_dubberword.html, autocompleteselectmultiple.html

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
  • I've been using ajax-select for FK fields in forms which are not in admin. So I tried experimenting since I have the package installed and setup on my dev server. Didn't have a M2M to test on, but I couldn't get a FK working in admin either. It would display the form, but not do any ajax lookups and wouldnt validate even if I put a valid value in. Thought I'd at least let you know I tried, but didn't find anything good. Best of luck. – j_syk Jul 12 '11 at 21:36
  • Thanks. I found a guy which seemed to have the same problem as yourself http://stackoverflow.com/questions/4872545/how-to-get-django-ajax-selects-to-work-in-django-admin – Pierre de LESPINAY Jul 13 '11 at 06:16
  • @Glide: I am not posting this message because I have a solution for you rather, I myself need some help in using `ajax-selects` There is a field named `arg_default` in `POSTMAN_AUTOCOMPLETER_APP` which has to be given some value as no default exists for it. But it is not mentioned in the docs what kind of value do we have to give. Can you please guide me in this. Any help is really appreciated – Sachin Dec 21 '11 at 15:36
  • @Sachin Sorry, I finally used [grappelli](http://sehmaschine.github.com/django-grappelli/) for the admin interface, which includes Autocomplete Lookups. – Pierre de LESPINAY Jan 09 '12 at 08:20
  • @Glide: Thanks for the input.. Actually I don't need autocomplete for the admin interface I need it for public pages as well... But I will figure out something. Thanks for the feedback – Sachin Jan 09 '12 at 12:17

1 Answers1

0

I used grappelli for the admin interface.
It supplies Autocomplete Lookups.

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307