TemplateDoesNotExist – Błąd Django

| | | |

Używam Django Rest Framework. i ciągle otrzymuję błąd

Typ wyjątku: TemplateDoesNotExist Wartość wyjątku: rest_framework/api.html 

Nie wiem, jak się mylę. To pierwszy raz, kiedy wypróbowuję REST Framework. To jest kod.

views.py

import socket, json from modules.data.models import * from modules.utils import * from rest_framework import status z rest_framework.decorators import api_view z rest_framework.response import Odpowiedź z modules.actions.serializers import ActionSerializer @api_view(["POST"]) @check_field_exists_wrapper( "instalacja") def api_actions(request, format = None): action_type = request.POST["action_type"] if action_type == "Zamknij" : send_message = "1" print "Zamykanie systemu..." elif action_type = = "Włącz" : send_message = "1" print "Włączanie systemu..." elif action_type == "Wyłącz" : send_message = "1" print "Wyłączanie systemu..." elif action_type == "Uruchom ponownie" : send_message = "1" print "Ponowne uruchamianie systemu..." if action_type in ["Shutdown", "Enable", "Disable"] : PORT = 6000 else : PORT = 6100 controllers_list = Controller.objects.filter (identyfikator_instalacji = kwargs["id_instalacji"]) for controller_obj in controllers_list: ip = controller_obj.ip try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((ip, PORT)) s.send( send_message) s.close() z wyjątkiem wyjątku jako e: print("Wyjątek podczas wysyłania " + typ_akcji +" polecenie: "+str(e)) return Response(status = status.HTTP_200_OK) 

models.py

class Controller(models.Model): id = models.IntegerField(primary_key = True) name = models.CharField(max_length = 255, unique = True) ip = models.CharField(max_length = 255, unique = True) install_id = models.ForeignKey("Instalacja") 

serializers.py

z django.forms importuj widżety z rest_framework importuj serializatory z modules.data.models import *

class ActionSerializer(serializers.ModelSerializer): class Meta: model = Pola kontrolera = („id”, „name”, „ip”, „installation_id”) 

urls.py< /strong>

z django.conf.urls importuj wzorce, url z rest_framework.urlpatterns importuj format_suffix_patterns urlpatterns = patterns("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