TemplateDoesNotExist – Errore Django

| | | |

Sto usando Django Rest Framework. e continuo a ricevere un errore

Tipo di eccezione: TemplateDoesNotExist Valore di eccezione: rest_framework/api.html 

Non so come sbaglio. Questa è la prima volta che provo REST Framework. Questo è il codice.

views.py

import socket, json da modules.data.models import * da modules.utils import * da rest_framework import status da rest_framework.decorators import api_view da rest_framework.response import Risposta da modules.actions.serializers import ActionSerializer @api_view(["POST"]) @check_field_exists_wrapper( "installazione") def api_actions(request, format = None): action_type = request.POST["action_type"] if action_type == "Spegnimento" : send_message = "1" print "Arresto del sistema..." elif action_type = = "Abilita" : send_message = "1" print "Abilitazione del sistema..." elif action_type == "Disabilita" : send_message = "1" print "Disabilitazione del sistema..." elif action_type == "Riavvia" : send_message = "1" print "Riavvio del sistema..." if action_type in ["Spegni", "Abilita", "Disabilita"] : PORT = 6000 else : PORT = 6100 controllers_list = Controller.objects.filter (installation_id = kwargs["installation_id"]) per 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() eccetto Eccezione come e: print("Eccezione durante l'invio " + action_type +" comando: "+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) Installation_id = models.ForeignKey("Installazione") 

serializers.py

da django.forms importa i widget da rest_framework importa i serializzatori da modules.data.models import *

class ActionSerializer(serializers.ModelSerializer): classe Meta: model = Controller fields = ("id", "name", "ip", "installation_id") 

urls.py< /strong>

da django.conf.urls importa modelli, url da rest_framework.urlpatterns import 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