해결됨: django는 포스트 매트릭스에서 배열을 추출합니다.

마지막 업데이트 : 09/11/2023

주요 문제는 Django가 사후 행렬에서 배열을 NumPy 배열이 아닌 Python 목록으로 추출한다는 것입니다. NumPy 배열이 그러한 종류의 작업에 훨씬 더 효율적이기 때문에 배열에서 어떤 종류의 수학적 연산을 수행해야 하는 경우 문제가 발생할 수 있습니다.

Django 보기에 게시하는 HTML 페이지에 행렬이 있습니다. 행렬은 목록의 목록이며 게시된 데이터에서 개별 목록을 추출하려고 합니다. 어떻게 해야 하나요?
지금까지 내가 가지고있는 것은 다음과 같습니다.
def myview(request):
if request.method == 'POST': # If the form has been submitted...
form = MyForm(request.POST) # A form bound to the POST data

if form.is_valid(): # All validation rules pass

# Process the data in form.cleaned_data

return HttpResponseRedirect('/thanks/') # Redirect after POST

else:
form = MyForm() # An unbound form

return render(request, 'mytemplate.html', {'form':form})

In mytemplate.html, 다음과 같은 체크박스 행렬이 있습니다.
<table><tr><td>1,1 <input type="checkbox" name="matrix[0][0]" value="1" /> </td> <td> 1,2 <input type="checkbox" name="matrix[0][1]" value="1" />" </td>" <"td"="" 1,3="" "="" input="" type="checkbox" name=matrix[0][2] value=1 /"" ""="" td="" tr="" table="" xtml-space:"preserve"" xmlns:xtml-space="http://www." w3corg/xml/1998/namespace"" xmlns_w3corg="/xmlns/" xml:"lang=en-us"" lang=en-us"" http://www."" w3corg/1999xhtml"" xmlns_w3corg="/1999/" html:"xmlns=http://www."" w3corg/" lang=en-us""" class="container">2,1 &"nbsp;" 2,2 "nbsp;" 2," 3 "nbsp;" 3," 1 "nbsp;" 3," 2 "nbsp;" 3," 3 "nbsp;" 4," 1 "nbsp;" 4," 2 "nbsp;" 4," 3 "" nbsp ; "" 5 , "" 1 "" nbsp ; "" 5 , "" 2 "" nbsp ; "" 5 , """ 6 ," """ 7 ," """ 8 ," """ 9 ," """ 10 ," """ 11 ," """ 12 ," """ 13 ," """ 14 , "
rntttt14,2
rn t t t 14

Related posts: