Отправка двух форм с помощью ajax независимо друг от друга с помощью Django

Я пытаюсь отправить две POST формы с помощью Django используя ajax, но только одна из форм имеет метод POST. Я не знаю, что делать, возможно, ошибка в Javascript, но я не понимаю, почему первая форма отправляется с методом POST, а вторая нет, я пытался искать в интернете, но думаю, что не нашел правильного вопроса.

(извините за мой плохой английский)

views.py

import os
import time
from datetime import datetime

from django.http import HttpResponse, StreamingHttpResponse
from django.shortcuts import render
from utils.camera_streaming_widget import CameraStreamingWidget


# Camera feed
def camera_feed(request):
    stream = CameraStreamingWidget()
    frames = stream.get_frames()

    return StreamingHttpResponse(frames, content_type='multipart/x-mixed-replace; boundary=frame')


def detect(request):
    stream = CameraStreamingWidget()
    success, frame = stream.camera.read()
    if success:
        status = True
    else:
        status = False
    return render(request, 'detect_barcodes/detect.html', context={'cam_status': status})

def dados(request):
    if request.method == 'POST':
        name = request.POST['name'] 
        print('HELLO')

        return HttpResponse(name)

def dados_cod(request):
    if request.method == 'POST':
        cod = request.POST['cod'] 
        print(cod)

        return HttpResponse(cod)

html

замените <form name="post-cod"> на <form id="post-cod">

Вернуться на верх