title: How to execute a function relative the request method with django rest framework?
body: <p>I'm trying to just show a message in terminal if a post requisition, for exemple, be executed.
  Here I've made these function &quot;get&quot; to be executed but it also doesn't work. :/</p>
  <pre><code> if request.method == 'POST':
       print(&quot;Requistion made&quot;)
  </code></pre>
  <p><strong>views.py</strong>:</p>
  <pre><code>from rest_framework import viewsets 
  from piecesapp.api import serializers
  from piecesapp import models
  
  
  from rest_framework import status
  from rest_framework.decorators import api_view
  from rest_framework.response import Response
  
  from rest_framework.decorators import api_view, permission_classes
  from rest_framework.permissions import IsAuthenticated
  from django.http import JsonResponse
  from django.views.decorators.csrf import csrf_exempt
  
  
  class PiecesViewSet(viewsets.ModelViewSet):
      serializer_class = serializers.PiecesSerializer
      queryset = models.Pieces.objects.all()
      def get(self, request, format=None):
          print(&quot;Oi&quot;)
          return Response(serializer_class.data)
  
      
  class BoardViewSet(viewsets.ModelViewSet):
      serializer_class = serializers.BoardSerializer
      queryset = models.Board.objects.all()
  </code></pre>
  <p>PS: I will remove this libs, it's just because i've tried some tutorials e it doesn't work.</p>
  <p><strong>urls.py:</strong></p>
  <pre><code>from django.urls import  include, path 
  from rest_framework import routers 
  from . import views 
  
  router = routers.DefaultRouter()
  
  router.register(r'pieces', views.PiecesViewSet)
  router.register(r'board', views.BoardViewSet)
  
  urlpatterns = router.urls
  </code></pre>
  <p><strong>models.py:</strong></p>
  <pre><code>from django.db import models
  import uuid
  
  # Create your models here.
  COLOR_CHOICES = (
      ('white','WHITE'),
      ('black', 'BLACK'),    
  )
  PICES_NAMES = (
      ('king','KING'),
      ('queen','QUEEN'),
      ('rook','ROOK'),
      ('bishop','BISHOP'),
      ('knight','KNIGHT'),
      ('pawn','PAWN'),
  )
  WHITE_KING_POSITION = ['e1']
  BLACK_KING_POSITION = ['e8'] 
  
  WHITE_QUEEN_POSITION = ['d1']
  BLACK_QUEEN_POSITION = ['d8']
  
  WHITE_ROOK_POSITION = ['a1','h1']
  BLACK_ROOK_POSITION = ['a8','h8']
  
  WHITE_BISHOP_POSITION = ['c1','f1']
  BLACK_BISHOP_POSITION = ['c8','f8']
  
  WHITE_KNIGHT_POSITION = ['b1', 'g1']   
  BLACK_KNIGHT_POSITION = ['b8', 'g8']   
  
  WHITE_PAWN_POSITION = ['a2', 'b2','c2','d2','e2','f2','g2','h2'] 
  BLACK_PAWN_POSITION = ['a7', 'b7','c7','d7','e7','f7','g7','h7'] 
  
  PIECE_POSITION_HORIZONTAL = (
      ('a','A'),
      ('b','B'),
      ('c','C'),
      ('d','D'),
      ('e','E'),
      ('f','F'),
      ('g','G'),
      ('h','H'),
  )
  PIECE_POSITION_VERTICAL = (
      ('1','1'),
      ('2','2'),
      ('3','3'),
      ('4','4'),
      ('5','5'),
      ('6','6'),
      ('7','7'),
      ('8','8'),
  )
  BOARD_DEFAULT_ID = 1
  class Pieces(models.Model):
      piece_id = models.AutoField(primary_key=True,editable= False) 
      piece_name = models.CharField(choices = PICES_NAMES, max_length=255)
      piece_color = models.CharField(choices = COLOR_CHOICES, max_length=5)  
      initial_position_h = models.CharField(default = &quot;a&quot;, choices=PIECE_POSITION_HORIZONTAL, max_length=50)
      initial_position_v = models.IntegerField(default = 1, choices=PIECE_POSITION_VERTICAL)
          
      chess_board = [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['1', '2', '3', '4', '5', '6', '7', '8']]
   
      def __int__(self):
          return self.piece_id
    
  class Board(models.Model):
      boardpiece_id = models.ForeignKey(Pieces, on_delete=models.CASCADE)
      position_x = models.CharField(choices = PIECE_POSITION_HORIZONTAL, default=&quot;PIECE POSITION&quot;, max_length=50)
      position_y = models.CharField(choices = PIECE_POSITION_VERTICAL, default=&quot;PIECE POSITION&quot;,max_length = 50)
      def __str__(self):
          return str(self.boardpiece_id)
     
  </code></pre>
  <p>It's basically a API to show some possible chess plays</p>