django-private-chat icon indicating copy to clipboard operation
django-private-chat copied to clipboard

IndexError at /chat/dialogs/ list index out of range

Open engrosshost opened this issue 7 years ago • 8 comments

I keep getting this error message check time i register new user and when new user try to visit /chat/dislogs/ page

HERE IS THE ERROR MESSAGE: IndexError at /chat/dialogs/

list index out of range

engrosshost avatar Dec 05 '17 14:12 engrosshost

Please provide more info

delneg avatar Mar 11 '18 16:03 delneg

Closing as of no response.

delneg avatar May 13 '18 17:05 delneg

I get this same issue, due to the line: context['active_dialog'] = self.object_list[0] (views.py line 37) I'd guess there should be something to test whether object_list is empty (the user has no open dialogs) before running this line.

zsmith3 avatar Jul 12 '18 13:07 zsmith3

Didn't look into the code for a while, could you suggest what should be context['active_dialog'] value then?

delneg avatar Jul 12 '18 13:07 delneg

The problem is that new users by default have no open dialogs, but the system currently relies on the first URL they go to being one with a username in, to start a new dialog with that person. The 'dialog.html' template assumes that context['active_dialog'] has a value, whereas for new users it should probably be set to None. I would suggest that ideally new users should be greeted with a "no dialogs yet" (or some such message) when they first view the page, and this would ideally need to give them some option to start a new dialog from a menu of other users. However this would require some (slightly more significant) addition to dialogs.html. I'd suggest there are several options:

  • Modify dialog.html with the proposed changes (time consuming)
  • Automatically create (empty) dialogs with other users, so that all users have some open dialogs by default. However this would still pose a problem for the first ever user, for whom there are no other possible users.
  • Leave as is, but perhaps redirect to a formal error page rather than just triggering a python error

zsmith3 avatar Jul 12 '18 14:07 zsmith3

I can work around it as it is in my current project, but if anyone has time to properly fix it that would be good.

zsmith3 avatar Jul 12 '18 14:07 zsmith3

How did you work around this?

arjun-krishna1 avatar Nov 02 '20 16:11 arjun-krishna1

You can add first dialog manual like that :http://127.0.0.1:8000/dialogs/[your_exist_one_username]

rufaidemir avatar Nov 13 '20 12:11 rufaidemir