我正在尝试用ajax_select替换SelectMultiple
默认小部件。
我按照安装指南,这是我的文件:
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)
尝试加载Dubber
对象的管理页面,我收到此消息
渲染时抓住TemplateDoesNotExist: autocompleteselectmultiple_dubberword.html, autocompleteselectmultiple.html
答案 0 :(得分:0)
我使用grappelli作为管理界面 它提供自动完成查找。