Sunday, July 22, 2012

Re: What does this error mean?

But user is logged in and authenticated. His other requests in same session has user and group. Why would few ajax calls not have it?


On Sunday, July 22, 2012 4:39:21 PM UTC-7, Russell Keith-Magee wrote:
On Mon, Jul 23, 2012 at 5:30 AM, ydjango wrote:
>
>
> [Django] ERROR (EXTERNAL IP): Internal Server Error:
>
>
>    File
> "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line
> 111, in get_response
>     response = callback(request, *callback_args, **callback_kwargs)
>
>   File "/home/ubuntu/webapps/myapp/core/views.py", line 7048, in loadmydata
>     my_group, my_address, my_url, my_name=  get_info_from_session(request)
>
>   File "/home/ubuntu/webapps/myapp/core/myutility.py", line 343, in
> get_info_from_session
>     my_group = request.user.groups.all()[0].id
>
>   File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py",
> line 173, in __getitem__
>     return self._result_cache[k]
>
> IndexError: list index out of range
>
> I get email from django with the  above error on above line. The application
> works fine. I do not notice any error on screen. I also do not see error in
> firebug in the network calls. The the view which contains above line is
> called from AJAX calls. I am logged into app and authenticated.
>
> Using Django 1.3.1 and Python 2.6
>
> I can ignore these emails. But any clue what can be causing it?

What is causing the error? Exactly what the error message says: You're
requesting a specific list index. That index is out of range.

Looking at the stack trace, you're trying to retrieve:

    request.user.groups.all()[0]

The error is being raised when there *isn't* an element 0 -- that is,
when a user has no groups.

Yours,
Russ Magee %-)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/SXTXfrRmUBwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment