Click here to Skip to main content
15,665,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making my first application with Django. The goal is to have a table rendered from my SQlite database that displays the current inventory of laboratory reagents. Once a reagent is taken out of storage a user will be able to hit a subtract button to subtract from the current inventory. Currently I have a table that displays the reagent name and quantity. I would like to add a column to the table that has a subtract button that will subtract one from the corresponding reagents current inventory.

Can anyone please give me some suggestions on how to implement a subtract button? Any help would be much appreciated.

What I have tried:


class Reagentquant(models.Model):

    Name_Of_Reagent= models.TextField()
    Reagent_Quantity= models.TextField()

class ReagentquantTable(tables.Table):
    class Meta:
        model = Reagentquant
        template_name = 'django_tables2/bootstrap4.html'

def reagentquant(request):
    table = ReagentquantTable(Reagentquant.objects.all())
    return render(request, 'inventory/quant.html', {'table': table})


{% load render_table from django_tables2 %}
<!doctype html>
        <title>Inventory Tracker</title>
        <link rel="stylesheet" href="" />
        {% render_table table %}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900