Merging results of two .html files show up in one web page

Skip to first unread message

Mee “MeeGrp” Grp

Jun 5, 2024, 3:40:02 AMJun 5
to Django users
I am working on an Inventory System ( just a trial - for learning purposes)

platform - Python
framework - Django

VS Code/Sqlite3 


I have two html files 1. view_sales.html 2.total_sales.html


<!DOCTYPE html>
    <title>Product Total_price</title>

    <table border="1">
            <th>Quantity Sold</th>          
            <th>Total Price</th>
        {% for sale in sales %}
            <td>{{ sale.product.product_name }}</td>
            <td>{{ }}</td>                      
            <td>{{ sale.amount }}</td>
            <td>{{ sale.quantity_sold}}</td>
            <td>{{ sale.total_price }}</td>


        {% endfor %}
    <h2>Total Sales: {{ total_sales }}</h2>    

Ryan Nowakowski

Jun 5, 2024, 5:07:27 PMJun 5
to 'Mee “MeeGrp” Grp' via Django users
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Bhagyashri Phalake

Jun 6, 2024, 12:43:46 PMJun 6
to Django users

total sale

from django.shortcuts import render
from .models import Sale

def sales_report(request):
    sales = Sale.objects.all()
    total_sales = sales.aggregate(total=models.Sum('total_price'))['total']
    return render(request, 'sales_report.html', {'sales': sales, 'total_sales': total_sales})

cal total sale:on view
from flask import Flask, render_template
from models import db, Sale

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///sales.db'

def sales_report():
    sales = Sale.query.all()
    total_sales = sum(sale.total_price for sale in sales)
    return render_template('sales_report.html', sales=sales, total_sales=total_sales)

if __name__ == '__main__':
Reply all
Reply to author
0 new messages