django-private-chat
django-private-chat copied to clipboard
IndexError at /chat/dialogs/ list index out of range
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
Please provide more info
Closing as of no response.
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.
Didn't look into the code for a while, could you suggest what should be context['active_dialog'] value then?
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
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.
How did you work around this?
You can add first dialog manual like that :http://127.0.0.1:8000/dialogs/[your_exist_one_username]