Я новичок ie в Django и не могу сопоставить мой пользовательский ввод с запросом моей хранимой процедуры.
views.py
from django.db import connection
from django.shortcuts import render
from .forms import InputForm
def home_view(request):
print("woooooooooooo",request)
context1 ={}
context1['form']= InputForm()
print("context1::::", context1)
return render(request, "input.html", context1)
def itemnumber(request):
cursor = connection.cursor()
try:
itemnumber = "23241715"
C=cursor.execute(f"EXEC ValidateBusinessrule '0000000000{itemnumber}'")
print("c value",C)
result_set = cursor.fetchall()
print(result_set)
result_set1= [' {} '.format(x) for x in result_set]
print(result_set1)
context = {"row": result_set1}
print("lolllllllllll", context)
return render(request, "home.html", context)
finally:
cursor.close()
print("hello3")
forms.py
from django import forms
import re
# creating a form
class InputForm(forms.Form):
print("inside forms")
regex = re.compile('^([1-9]{8})$', re.UNICODE)
ENTER_ITEM_NUMBER= forms.RegexField(max_length=8, regex=regex,help_text=("Required 8 digits
between {0-9}."))
print("iiiiiiiiiiiiiiiiiiiiiiii",ENTER_ITEM_NUMBER)
#ENTER_ITEM_NUMBER = forms.IntegerField(max_length=8, label='ENTER ITEM NUMBER')
item / urls
from django.urls import path
from django.urls import include, path
#from django.urls import path
from . import views
urlpatterns = [
path('inputs/', views.home_view),
path('item/', views.itemnumber, name='item'),
]
print("hello1")
input. html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action = "" method = "post">
{% csrf_token %}
{{form }}
<input type="submit" value=Submit">
</form>
</body>
</html>
Home. html
<html>
<style>
body
{
background-color: powderblue;
}
</style>
<body>
<table style="border: 1px solid #b50b32; margin: 30px auto; width: 100px; padding: 0; border-spacing: 10px;" bgcolor="#00FF00" cellspacing="0" cellpadding="10">
<tr>
<ul>
<th>(u,v)</th>
</ul>
</tr>
<tr>
<ul >
{% for row in row %}
<td style= "text-align: center;">
{{ row }}
</td>
</ul>
</tr>
{% endfor %}
</table>
</body>
</html>
Я не использую никакую модель. *
( Могу ли я получить форму Django без модели )
Я запутался Как я могу передать свой пользовательский ввод = ENTER_ITEM_NUMBER номеру элемента def (запрос ) .
чтобы все работало нормально?