[Answered ]-I'm trying to add a search functionality to my ListView but it gives Method Not Allowed (POST): error

1๐Ÿ‘

โœ…

A search is normally done through a GET request, not a POST request: POST requests are usually used to create, update and delete entities.

So your form should have method="GET":

<form class=" my-2 my-lg-0 d-flex flex-row-reverse" method="GET" action="{% url 'memes:all' %}">
    โ€ฆ
</form>

Since this is a GET request, it is not necessary to use {% csrf_token %} since cross-site request forgery will not result in creating, updating or removing an entity.

Leave a comment