[Fixed]-Django csrf_token in search result url

24👍

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

4👍

you added {% csrf_token %} in your form. if you dont need csrf remove this from your form and add csrf_exempt.

look at this sample of django:

from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def my_view(request):
     return HttpResponse('Hello world')

1👍

I would assume that you’ve added the {% csrf_token %} within one of the search form’s input element. That would cause the token to be submitted along with the form.

Check your search form template.

Leave a comment