'How to enable POST,PUT for django rest framework viewset

I have simple viewset like this

in views.py

class MyFileViewSet(viewsets.ViewSet):
    http_method_names = ['post','get','put']
    def list(self, request):
        queryset = MyFile.objects.all()
        serializer = MyFileSerializer(queryset, many=True)
        return Response(serializer.data)

models.py

from xml.dom.minidom import DOMImplementation
from django.db import models


class MyModel(models.Model):
    name = models.CharField(verbose_name='NAME', max_length=30)
    file = models.FileField(upload_to='file/%Y/%m/%d')
    is_transfer_finish = models.BooleanField(default=False)
    created_at = models.DateTimeField(verbose_name='created', auto_now_add=True)

Now I can see the list of MyModel.

However I want to set post and push for this model,

I set

http_method_names = ['post','get','put']

But currently, there is only 'GET' on html.

I want to enable POST or PUT to create new entry.

Is it possible? how can I make this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source