2

I am currently using an application named django-postman that makes use of django-ajax-selects to provide autocomplete feature in user names when sending messages internally. The view shown in django-ajax-selects is quite neat, but when I actually used it, the view of the dropdown was prety crude.

I have attached a screenshot. Can anybody please help in knowing why am I getting this basic crude view. enter image description here

As can be seen here the suggested name is coming right at the end. I also wanted to know if I can add the user gravatar, along with their name to make it more visually appealing.

Sachin
  • 3,672
  • 9
  • 55
  • 96
  • If you ever figured this out, I would really appreciate looking at a piece of your code to help me with this issue. Thanks for any ideas! – Nick B Oct 25 '12 at 03:18
  • Nick, I had asked this question a long time back, and now the ajax select works well for me. I am sorry I don't even remember how I solved it. I will look up the code and try to get back to you – Sachin Oct 26 '12 at 04:11
  • That would be great! I appreciate any snippets that you may offer! Have a good day – Nick B Oct 26 '12 at 17:21
  • Hi @NickB I know its kind of late but I was really busy over the last month. I have added an answer, you can have a look at it. Hope it helps you. – Sachin Nov 29 '12 at 07:33

1 Answers1

1

I eventually figured out how to solve this problem, but did not update this answer. But since I have received comments, I think I should share whatever I know. I don't exactly remember what did I do write so that it started working correctly, but I will share all the settings that I have made in my files, and hope it works for others as well

Firstly I installed django-ajax-selects for the autocomplete field. here is the link for the app https://github.com/crucialfelix/django-ajax-selects

After having installed in project you need these specific settings in the settings file

POSTMAN_AUTOCOMPLETER_APP = {    {% if is_autocompleted %}
 <script type="text/javascript" src="{{ STATIC_URL }}js/jquery.autocomplete.min.js"></script>
<link href="{{ STATIC_URL }}css/jquery.autocomplete.css" type="text/css" media="all" rel="stylesheet" />
 {% endif %}
        'name': 'ajax_select',
        'field': 'AutoCompleteField',
        'arg_name': 'channel',
        'arg_default': 'user', # no default, mandatory to enable the feature
}

AJAX_SELECT_BOOTSTRAP = True
AJAX_SELECT_INLINES = 'inline'

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

You need to include the jquery autocomplete file in your template. Now this library has been integrated with jquery ui so make sure that you use the old jquery autocomplete js file. This could potentially be one of the reasons for it not working.

{% if is_autocompleted %}
 <script type="text/javascript" src="{{ STATIC_URL }}js/jquery.autocomplete.min.js"></script>
<link href="{{ STATIC_URL }}css/jquery.autocomplete.css" type="text/css" media="all" rel="stylesheet" />
 {% endif %}

As I said, I don't exactly remember what I did, such that the app started working but these are all the settings that exist in my project.

Thanks

Sachin
  • 3,672
  • 9
  • 55
  • 96