TemplateDoesNotExist – Django 오류

| | | |

Django Rest Framework를 사용하고 있는데 계속 오류가 발생합니다.

예외 유형: TemplateDoesNotExist 예외 값: rest_framework/api.html 

내가 어떻게 잘못되고 있는지 모르겠어요. 처음으로 REST Framework를 사용해 봤습니다. 이것은 코드입니다.

view.py

import socket, json from modules.data.models import * from modules.utils import * from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import 응답 from modules.actions.serializers import ActionSerializer @api_view(["POST"]) @check_field_exists_wrapper( "설치") def api_actions(요청, 형식 = 없음): action_type = request.POST["action_type"] if action_type == "Shutdown" : send_message = "1" print "시스템 종료 중..." elif action_type = = "활성화" : send_message = "1" print "시스템 활성화..." elif action_type == "비활성화" : send_message = "1" print "시스템 비활성화..." elif action_type == "다시 시작" : send_message = "1" print "시스템 재시작 중..." if action_type in ["Shutdown", "Enable", "Disable"] : PORT = 6000 else : PORT = 6100 controllers_list = Controller.objects.filter (installation_id = kwargs["installation_id"]) controller_obj의 controllers_list: ip = controller_obj.ip 시도: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((ip, PORT)) s.send( send_message) s.close() 예외 e: print("전송 시 예외 " + action_type +" 명령: "+str(e)) return Response(status = status.HTTP_200_OK) 

models.py

클래스 컨트롤러(models.Model): id = models.IntegerField(primary_key = True) 이름 = models.CharField(max_length = 255, unique = True) ip = models.CharField(max_length = 255, unique = True) installation_id = models.ForeignKey("설치") 

serializers.py

django.forms에서 위젯 가져오기 rest_framework에서 위젯 가져오기 module.data.models에서 직렬 변환기 가져오기 *

class ActionSerializer(serializers.ModelSerializer): 클래스 메타: 모델 = 컨트롤러 필드 = ("id", "name", "ip", "installation_id") 

urls.py< /strong>

django.conf.url에서 패턴 가져오기, rest_framework.urlpatterns에서 URL 가져오기 format_suffix_patterns urlpatterns = 패턴("modules.actions.views", url(r"^$"," api_actions",name="api_actions"), ) 

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method