Reputation: 23
Whenever I try to update an itinerary with primary key using PUT request I get HTTP 404 detail": "Not found."
api views.py
class updateTempItinerary(generics.UpdateAPIView):
queryset = tempItinerary.objects.all()
serializer_class = tempItinerarySerializer
permission_classes = (permissions.AllowAny,)
api urls.py
url(r'^updatetempitinerary/$(?P<pk>)(?P<itineraryID>)(?P<destinations>)(?P<hotels>)', views.updateTempItinerary.as_view()),
itinerary models.py
class tempItinerary(models.Model):
itineraryID = models.CharField(max_length=100, unique=True)
user = models.CharField(max_length=100)
country = models.IntegerField()
destinations = models.CharField(max_length=100, default='None')
hotels = models.CharField(max_length=100, default='None')
travelClass = models.CharField(max_length=100)
date = models.DateField()
travelers = models.IntegerField(default=1)
def __unicode__(self):
return '%s %s %s %s %s %s %s %s ' % (self.pk, self.travelers, self.date, self.travelClass, self.hotels, self.destinations, self.country, self.itineraryID, self.user)
URL im testing on
127.0.0.1:8000/api/updatetempitinerary/?pk=1&format=json&
Upvotes: 0
Views: 4125
Reputation: 1645
As Booby suggested your url is wrong. If you are using PUT request I suggest your that your remove your url arguments except id. So it will look like so: url(r'^updatetempitinerary/(?P<id>[0-9]+)/$', views.updateTempItinerary.as_view()),
That is all (notice there is a $ sign at the end).
If this does not work please provide your serializers and full error traceback. You can update your model on 127.0.0.1:8000/api/updatetempitinerary/1/
.
Upvotes: 1