So i want to take the user input and compare it to data present in the sqlite3 db, and if matches I'd like to print that whole row, using django orm.
models.py
from django.db import models
class Inventory(models.Model):
item_bc = models.CharField(max_length=100)
item_details = models.CharField(max_length=100)
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('search', views.search, name='search'),
]
views.py
from django.shortcuts import render
from django.http import HttpResponse
from models import Inventory
# Create your views here.
def index(request):
return render(request, 'form.html')
def search(request):
search_input = request.POST.get('barcode')
data = Inventory.objects.filter(item_bc=search_input).values()
return render(request, 'result.html', {"data": data})
I really appreciate your time and help, thank you!
i think adding logic to the search function to compare should work but extremely new to django and dont really know on how to start..