0
每當我嘗試使用PUT請求更新具有主鍵的行程時,我將獲取HTTP 404詳細信息」:「未找到。Django rest框架http 404詳細信息「:」找不到「
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()),
行程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測試上
127.0.0.1:8000/api/updatetempitinerary/?pk=1&format=json&
它似乎你在URL中缺少一些參數? – Bobby