使用Rest Framework发布Api

So I was tring to create a POST Api for my project where on the html page, user enter his details and message and press the encrypt button, then an encrypted msg should be shown in the container given below and his details should be stored in DB.

Here is the image of what the page is like. write imgur dot com here/a/3hnAA

https://imgur.com/a/30U17 --> I've created a POST Api but the request going is get. Please can anybody check and tell where I'm going wrong

But the problem is as you can see encrypted message is shown below but the post api is not working.

All i want is to create an entry in DB and the user also stay on this page only.

Here are my Django file. All the files can be found here. https://github.com/MukulLatiyan/Vigenere-Cipher

models.py

from __future__ import unicode_literals

from django.db import models

class User(models.Model):
    name = models.CharField(max_length=255)
    email = models.CharField(max_length=255)
    message = models.TextField(max_length=40000)
    enc_message = models.TextField(max_length=40000)
    created_on = models.DateTimeField(auto_now_add=True)

views.py

from __future__ import unicode_literals
from models import User
from forms import MainForm
from django.shortcuts import render
from serializers import UserSerializer
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from rest_framework.permissions import AllowAny


def main_view(request):
    if request.method == "POST":
        form = MainForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            message = form.cleaned_data['message']
            enc_message = form.cleaned_data['enc_message']

            ## SAVING DATA TO DB

            user = User(name=name, email=email, message=message, 
enc_message=enc_message)
            user.save()
            return render(request, 'success.html')

    else:
        form = MainForm()

    return render(request, 'index.html', {'form': form})

class UserList(APIView):

    permission_classes = (AllowAny)
    def post(self, request, format=None):
        user = User.objects.create()
        serializer = UserSerializer(data=request.data)
        if serializer.is_valid():
            serializer.save(user)
            return Response(serializer.data, 
status=status.HTTP_201_CREATED)
        return Response(serializer.errors, 
status=status.HTTP_400_BAD_REQUEST)

serializers.py

class UserSerializer(serializers.ModelSerializer):

    class Meta:
        model = User
        fields = ['name', 'email', 'message', 'enc_message']

and this is the ajax call in js file.

function getCookie(name) {
    var cookieValue = null;
    if (document.cookie && document.cookie !== '') {
        var cookies = document.cookie.split(';');
        for (var i = 0; i < cookies.length; i++) {
            var cookie = jQuery.trim(cookies[i]);
            // Does this cookie string begin with the name we want?
            if (cookie.substring(0, name.length + 1) === (name + '=')) {
                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                break;
            }
        }
    }
    return cookieValue;
}
var csrftoken = getCookie('csrftoken');

//Function for the Post Api Call
var data = '{"inputs":[{"data":{"name":{"email":{"msg":{"enc_msg"}}}]}'
$("encrypt_button").on("click", function(e){
    e.preventDefault();
    $.ajax({
        'type': 'POST',
        'url': '/users',
        'data': {
            'csrfmiddlewaretoken' : csrftoken,
            'data': data,
        },
        success: function (response) {
            console.log("HIGH");
            console.log(response.outputs);
        },
        error: function (xhr) {
            console.log("HIGH");
            console.log(xhr);
        }
    })
})