3
The reason this fails is because you have two functions that have the same name, so it will call the update_label
that you defined in the name.
You can fix this by importing the function with a different name, so:
from custom_label.services.custom_label_svc import update_label as update_label_logic
@api_view(['POST'])
@authorize
def update_label(request) -> JsonResponse:
try:
payload = ValidateUpdateLabel(data=request.data)
if payload.is_valid():
# call service methods
data = update_label_logic(payload.validated_data)
# β¦
But wrapping the entire logic in a try
βexcept
is usually not a good idea. Furhtermore your function is vulnerable to SQL injection.
Source:stackexchange.com