django-postman + django-ajax-selects usage

Issue #63 closed
Nuno Khan
created an issue

So i have just started using django-postman==3.2.2 and i am trying to integrate auto-complete using django-ajax-selects==1.3.6 while using django-authtools==1.2.0 to have a custom user model with no luck.

    'postman_users': dict(model='authtools.user', search_field='email'),
    'arg_default': 'postman_users',
AUTH_USER_MODEL = 'authtools.User'

I tried changing from model='authtools.user to model='auth.user but it doesn't work.

from ajax_select import urls as ajax_select_urls

url(r'^messages/', include('postman.urls')),

I then go to the built in postman view http://localhost:8000/messages/write/ and when i fill the recipients input nothing happens.

What am i missing? Isn't this supposed to work with just these settings?

Comments (12)

  1. Patrick Samson repo owner
    • changed status to open

    In simple lookup channel, quoted from ajax_selects site: "To ensure that nobody can get your data via json simply by knowing the URL. The default is to limit it to request.user.is_staff and raise a PermissionDenied exception.".

    Set the is_staff flag on the User used for your try, to confirm this assertion.

    Knowing this, for a production usage, you may have to build a custom lookup channel implementation.

    Note: contrary to the site, the error code is 403, not 401.

  2. Patrick Samson repo owner

    v1.2.5 does work on Django 1.5, but not more :(

    I found a fix for a single entry. Now, for multiple entries as "user1, user2", the javascript has to be reviewed because all this part has been re-factored in version 1.3.

  3. Nuno Khan reporter

    @Patrick Samson i installed the latest version on pip and i am still not able to get this working out of the box just by going to http://localhost:8000/messages/write/ and keeping the same settings as above.

    i created a postman/templates/autocomplete.html and copied the code in autocomplete_postman_multiple_as1-3.html to it. I even setup an aditional channel:

        'postman_users': dict(model='authtools.user', search_field='email'),
        'postman_multiple_as1-3': dict(model='authtools.user', search_field='email'),

    I guess i am still missing something. using django-ajax-selects==1.3.6 and django-postman==3.3.0

    By the way, i have django-ajax-selects working by itself in the admin

  4. Patrick Samson repo owner

    You are the only one who can debug your configuration. Think back to my first comment.

    Trace the request, both on browser side and server side, and you will find the lacks.

  5. Nuno Khan reporter

    @Patrick Samson as a workaround i ended up using django-autocomplete-light which i found much easier to use and understand than django-ajax-selects

    I then created my own extended form and passed to the write view:

    class MyCustomWriteForm(BaseWriteForm):
        recipients = autocomplete_light.ChoiceField(
            'UserAutocomplete', label='recipients')
        class Meta(BaseWriteForm.Meta):
            fields = ('recipients', 'subject', 'body')

    in my

    url(r'^messages/write/(?:(?P<recipients>[^/#]+)/)?$', WriteView.as_view(form_classes=(MyCustomWriteForm, AnonymousWriteForm)), name='write'),

  6. Log in to comment