【问题标题】:How to declare a LOOKUP CHANNEL for django user model in django ajax-selects如何在 django ajax-selects 中为 django 用户模型声明一个 LOOKUP CHANNEL
【发布时间】:2012-01-25 10:33:36
【问题描述】:

我正在使用django-postman 提供用户对用户的消息功能,这使用 django ajax-selects 在发送消息时为用户名提供autocomplete 功能。我需要为 Django 用户声明一个频道并将其传递给postman 应用程序。这里必须怎么做。我声明了一个频道,如下所示,

AJAX_LOOKUP_CHANNELS = {
    #   pass a dict with the model and the field to search against
    'user'  : {'model':'django.contrib.auth.User', 'search_field':'username'},
}

在这里我将它传递给postman 应用程序

POSTMAN_AUTOCOMPLETER_APP = {
        'name': 'ajax_select', 
        'field': 'AutoCompleteField',
        'arg_name': 'channel', 
        'arg_default': 'user', # no default, mandatory to enable the feature
    }

但是当我这样做时,我会得到一个template syntax error 作为Caught ValueError while rendering: too many values to unpack

谁能帮我知道这里到底发生了什么。

【问题讨论】:

    标签: ajax django autocomplete django-templates


    【解决方案1】:
    AJAX_LOOKUP_CHANNELS = {
        'user'  : {'model': 'auth.user', 'search_field': 'username'},
    }
    

    'django.contrib.auth.User' 更改为'auth.user'

    【讨论】:

      猜你喜欢
      • 2015-10-20
      • 2011-06-19
      • 1970-01-01
      • 2011-08-14
      • 2012-01-25
      • 2012-04-30
      • 1970-01-01
      • 1970-01-01
      • 2015-01-04
      相关资源
      最近更新 更多