title: I'm new to Django Rest_Framework. I am trying to implement a function-based view but facing problem with the put method
body: <p>I want to know how to access a particular object given a particular ID, and then update it. I'm currently getting the "405 method not allowed" error.</p>
  
  <p>Is it possible to access an object via an ID, as mentioned above, or do I have to approach the problem in a different way?</p>
  
  <p>My code is as currently as follows:</p>
  
  <p>views.py</p>
  
  <pre><code>from rest_framework import status
  from rest_framework.decorators import api_view
  from rest_framework.response import Response
  from home.models import example
  from home.serializers import exampleSerializer
  
  @api_view(['GET', ])
  def exampleview(request):
      try:
          ex=example.objects.all()
      except example.DoesNotExist:
          return Response(status=status.HTTP_404_NOT_FOUND)
  
      if request.method=="GET":
          serializer=exampleSerializer(ex, many=True)
          return Response(serializer.data)
  
  @api_view(['PUT', ])
  def exampleputview(request):
      try:
          ex1=example.objects.get(id=id)
      except example.DoesNotExist:
          return Response(status=status.HTTP_404_NOT_FOUND)
  
      if request.method=="PUT":
          serializer=exampleSerializer(ex1, data=request.data)
          if serializer.is_valid():
              serializer.save()
              return Response(serializer.data)
          return Response(status=status.HTTP_404_NOT_FOUND)
  
  urls.py
  from django.contrib import admin
  from django.conf.urls import url
  from home import views
  
  urlpatterns = [
      url('admin/', admin.site.urls),
      url('home/',views.exampleview),
      url('home/&lt;int:id&gt;/',views.exampleputview),
  ]
  </code></pre>