noisebridge / pyclass-project

Other
8 stars 2 forks source link

New search_interests() function throws AssertionError "No exception supplied" #17

Closed Belgand closed 12 years ago

Belgand commented 12 years ago

I started adding in additional functionality to the search function by letting it search for either interests or users (and display their interests). The code looked good and the basics of the implementation held up in the interpreter, but while I was testing it I started running into an error. The search page will load correctly and the form seems to be working properly, but when you start actually running a search Django throws out:

AssertionError at /search/

No exception supplied

with the trace pointing to line 27 in the view. I've played around with it a bit and it seems like it's having some sort of trouble with the render() call. Removing the context being passed in didn't solve the problem. Likewise I was still getting it if I commented out all of the new code and reverted back to:

 if form.is_valid():
            query = form.cleaned_data["query"]
            interests = Interest.objects.filter(name__icontains=query)
            return render(request, "profiles/search_results.html",
                                     {"interests": interests, "query": query})

I'd get the same error coming from return render(...) despite the old code working correctly in the past.

Even pulling out all the other code until I just had:

 if form.is_valid():
                return render(request, "profiles/search_results.html")

wasn't enough to solve it.

I've committed the code as branch SearchByUser and would appreciate it if others could look it over and help me resolve this.

eleddy commented 12 years ago

I would put in a pdb at line 26 and follow through the exception.

import pdb; pdb.set_trace()

To step into the render funtion, type 's' or 'step'

We can go over this on Tuesday as well if you haven't pdb'd before.

On May 13, 2012, at 5:49 PM, Mark Smith wrote:

I started adding in additional functionality to the search function by letting it search for either interests or users (and display their interests). The code looked good and the basics of the implementation held up in the interpreter, but while I was testing it I started running into an error. The search page will load correctly and the form seems to be working properly, but when you start actually running a search Django throws out:


No exception supplied

with the trace pointing to line 27 in the view. I've played around with it a bit and it seems like it's having some sort of trouble with the render() call. Removing the context being passed in didn't solve the problem. Likewise I was still getting it if I commented out all of the new code and reverted back to:

``python if form.is_valid(): query = form.cleaned_data["query"] interests = Interest.objects.filter(name__icontains=query) return render(request, "profiles/search_results.html", {"interests": interests, "query": query})


I'd get the same error coming from `return render(...)` despite the old code working correctly in the past.

Even pulling out all the other code until I just had:
``python
if form.is_valid():
               return render(request, "profiles/search_results.html")

wasn't enough to solve it.

I've committed the code as branch SearchByUser and would appreciate it if others could look it over and help me resolve this.


Reply to this email directly or view it on GitHub: https://github.com/noisebridge/pyclass-project/issues/17

Belgand commented 12 years ago

The problem was simpler than I was making it and became apparent when I considered what the common element of all the test cases I ran were: the template "search_results.html". I'd used {% else if ... %} rather than {% elif ... %} and it was choking on that.