title: How to make POST requests to class-based Views in Django
body: <p>I have created different class-based views on Django. On the HTML i created some forms make a request with AJAX. My problem is that it gives me</p>
  
  <p>Method Not Allowed (POST)</p>
  
  <p>I don know if i'm doing it rigth, or if i need to modify something for it to work.</p>
  
  <p>My view.py is something like this</p>
  
  <pre><code>class Landing(View):
      def get(self,request):
          if request.method == 'POST':
              if request.is_ajax():
                  data = {"lat":20.586, "lon":-89.530}
                  print request.POST.get('value')
                  return JsonResponse(data)
      return render(request,'landing.html',{'foo':'bar'})
  </code></pre>
  
  <p>And i send the reques from Javascript </p>
  
  <pre><code>$(document).ready(function() {
    $('#productos').on('change', function(e) {
       //Call the POST
       e.preventDefault();
       var csrftoken = getCookie('csrftoken');
       var value = $('#productos').val();
  
       $.ajax({
          url: window.location.href,
          type: "POST",
          data: {
              csrfmiddlewaretoken : csrftoken,
              value : value
          },
          success : function(json) {
              console.log(json);
              drop(json);
          },
          error : function(xhr,errmsg,err){
              console.log(xhr.status+": "+xhr.responseText)
          }
       });
    });
  });
  </code></pre>
  
  <p>I got some of the code from a web, but i really don't know how to use it, since they used it without class-based views.</p>
  
  <p>So, What does need my code to accept the POST method?</p>