2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 19:45:46 +00:00

Fix generation of API documentation

- Can't use get_object_or_404 in API views!
This commit is contained in:
Oliver
2021-10-17 22:32:03 +11:00
parent 7c5c1b6696
commit 6ebb956c8d
2 changed files with 21 additions and 6 deletions

View File

@ -7,7 +7,6 @@ from __future__ import unicode_literals
from django.conf.urls import url, include
from django.db.models import Q, F
from django.shortcuts import get_object_or_404
from django_filters import rest_framework as rest_filters
from rest_framework import generics
@ -235,7 +234,11 @@ class POReceive(generics.CreateAPIView):
context = super().get_serializer_context()
# Pass the purchase order through to the serializer for validation
context['order'] = get_object_or_404(PurchaseOrder, pk=self.kwargs.get('pk', None))
try:
context['order'] = PurchaseOrder.objects.get(pk=self.kwargs.get('pk', None))
except:
pass
context['request'] = self.request
return context