On Feb 3, 8:06 pm, Chris McComas <mccomas.ch...@gmail.com> wrote:
> Sorry,
>
> I've tried a few things...
>
> What kind of sucks is I'm just getting an IndexError: list index out
> of range which isn't very descriptive.
>
> I know the 'lor' query works, I tweaked my view to this:
>
> http://dpaste.com/154251/
>
> I just put a HttpResponseRedirect below the 'if lor:' to make sure
> that was working and it is working, so the problem as I can tell is
> with the line(s) if lor.rating_recommendation == "I highly recommend
> this applicant without any reservations."
>
> I tried to change it tohttp://dpaste.com/154252/but that's not right
> and threw a bad syntax error.
>
> The field rating_recommendation is a CharField in my model/db.


This would have been a whole lot easier to debug if you would have
posted the entire traceback, rather than a vague reference to
IndexError. Tracebacks give a whole load of information, and they do
so for a reason - to make debugging simple.

In any case, the latest code at least shows where you are getting
'lor'. In this case, lor is a queryset - that is, a list-like
collection of model instances. Each Recommendation in the queryset has
'rating_recommendation' properties, but the whole queryset doesn't
have one, hence the error. The [:1] at the end slices the queryset to
contain a single instance, but it's still a queryset rather than an
instance.

If you just want a single instance, use [0] at the end rather than [:
1].
--
DR

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

Reply via email to