title: Why the 'post' method is not working in my django app?
body: <p>I am using Django to develop a blog and when I wanted to get the contact informations, the post request seems not working at all. In the contacts view I don't do much I just wanted to make sure that the post request is working but it returns a Get request instead and the get method is working really fine<br />
  <strong>the javascript file</strong></p>
  <pre><code>  //CONTACT FORM
  $('#contactform').submit(function(){
    var action = $(this).attr('action');
    $(&quot;#message&quot;).slideUp(750,function() {
    $('#message').hide();
    $('#submit').attr('disabled','disabled');
    $.post(action, {
      name: $('#name').val(),
      email: $('#email').val(),
      comments: $('#comments').val()
    },
      function(data){
        document.getElementById('message').innerHTML = data;
        $('#message').slideDown('slow');
        $('#submit').removeAttr('disabled');
        if(data.match('success') != null) $('#contactform').slideUp('slow');
        $(window).trigger('resize');
      }
    );
    });
    return false;
  });
  </code></pre>
  <p><strong>view.py</strong></p>
  <pre><code>from django.http.response import HttpResponse
  from contact.forms import ContactForm
  from django.shortcuts import render
  from django.views.decorators.csrf import csrf_exempt
  @csrf_exempt
  # Create your views here.
  def contacts(request):
  if request.method == &quot;POST&quot; and request.is_ajax:
      print('hello!!')
      
      return render(request, 'contact/contact.html')
  </code></pre>
  <p><strong>forms.py</strong></p>
  <pre><code>from django import forms
  from .models import Contact
  class ContactForm(forms.Form):
       class Meta:
           model = Contact
           fields = ['cont_name', 'cont_email', 'cont_message', 'cont_date']
  </code></pre>
  <p><strong>models.py</strong></p>
  <pre><code>from django.db import models
  from datetime import datetime
  
  class Contact(models.Model):
      cont_name = models.CharField( max_length = 10)
      cont_email = models.EmailField()
      cont_message = models.TextField(blank=False)
      cont_date = models.DateTimeField(default=datetime.now, blank=True)
  
      def __str__(self):
          return self.cont_name
  </code></pre>
  <p><strong>contact.html</strong></p>
  <pre><code> &lt;div class=&quot;container&quot;&gt;
        &lt;div class=&quot;row&quot;&gt;
            &lt;div class=&quot;col-md-6&quot;&gt;
                &lt;p class=&quot;lead&quot;&gt;Sold old ten are quit lose deal his sent. You correct how sex several far distant believe journey parties. We shyness enquire uncivil affixed it carried to. &lt;/p&gt;
                &lt;p&gt;End sitting shewing who saw besides son musical adapted. Contrasted interested eat alteration pianoforte sympathize was. He families believed if no elegance interest surprise an. It abode wrong miles an so delay plate.&lt;/p&gt;
                
            &lt;/div&gt;
  
            &lt;div class=&quot;col-md-6&quot;&gt;
                &lt;div id=&quot;message&quot;&gt;&lt;/div&gt;
                &lt;form method=&quot;post&quot; action=&quot;{% url 'contacts' %}&quot; id=&quot;ContactForm&quot; class=&quot;main-contact-form wow&quot;&gt;
                    {% csrf_token %}
                    &lt;input type=&quot;text&quot; class=&quot;form-control col-md-4&quot; name=&quot;name&quot; placeholder=&quot;Your Name *&quot; id=&quot;name&quot; required data-validation-required-message=&quot;Please enter your name.&quot; /&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control col-md-4&quot; name=&quot;email&quot; placeholder=&quot;Your Email *&quot; id=&quot;email&quot; required data-validation-required-message=&quot;Please enter your email address.&quot; /&gt;
                    &lt;textarea name=&quot;comments&quot; class=&quot;form-control&quot; id=&quot;comments&quot; placeholder=&quot;Your Message *&quot; required data-validation-required-message=&quot;Please enter a message.&quot;&gt;&lt;/textarea&gt;
                    &lt;input class=&quot;btn btn-primary btn-theme&quot; type=&quot;button&quot; name=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
                &lt;/form&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
  </code></pre>
  <p><strong>urls.py</strong></p>
  <pre><code>from django.urls import path, reverse
  from . import views
  
  urlpatterns = [
       path('', views.contacts, name= 'contacts'),
  </code></pre>
  <p>]</p>