Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django csrf_token in search result url

Have csrf in search result url. Don't know why is there and how to remove it. Search works nice. Here is URL

/search/?csrfmiddlewaretoken=675d1340034e094866d15a921407e3fc&q=testing

here is view:

def search(request):
    query = request.GET.get('q', '')
    rezult = []
    if query:
    qset1 = (
        Q(title__icontains=query) 
    )
    result = Product.objects.filter(qset1).distinct()
    if result.count() == 1:
        return HttpResponseRedirect(result[0].get_absolute_url())
    return render_to_response('search/search.html',{'query': query, 'result': result, },context_instance=RequestContext(request))

Thanks

like image 209
Goran Avatar asked Feb 24 '13 09:02

Goran


1 Answers

Remove {% csrf_token %} from your form in the template, you don't need it since you're making a GET request.

like image 109
Ben Eliott Avatar answered Oct 11 '22 21:10

Ben Eliott