VOOZH about

URL: https://www.geeksforgeeks.org/python/receipt-print-with-gui-using-django/

⇱ Receipt Print with GUI using Django - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Receipt Print with GUI using Django

Last Updated : 23 Jul, 2025

In this article, we will guide you through creating a Recipe Print GUI. To achieve this, we first establish a login system, allowing sellers to create accounts through registration and subsequent login. Once logged in, we provide a straightforward form where sellers input the name, price, and quantity of materials. After clicking the "Add" button, the system calculates the total by multiplying the price and quantity, and the sum is displayed in a table at the bottom. Sellers can conveniently manage their data by accessing options to delete or update entries with a single click. When ready, they can generate bills effortlessly by clicking the "Generate Bill" button. Finally, sellers can log out with a simple click on the "Logout" button.

Receipt Print with GUI using Django

Sellers can conveniently manage their data by accessing options to delete or update entries with a single click. When ready, they can generate bills effortlessly by clicking the "Generate Bill" button. Finally, sellers can log out with a simple click on the "Logout" button.

To install Django follow these steps.

Starting the Project Folder

To start the project use this command

django-admin startproject core
cd core

To start the app use this command

python manage.py startapp home

Now add this app to the 'settings.py'

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"home",
]

File Structure

👁 file-for-GUI
file Structure

Setting Necessary Files

models.py: This Django model defines a Receipt with fields for user association, name, price, quantity, and total. It includes a foreign key to the User model and sets default values for the fields.

views.py: The functions in the view file collectively build a Django web application for managing receipt data, user accounts, and generating PDFs.

Creating GUI

login.html: This HTML code is for a basic login page within a Bootstrap-styled container. It includes fields for a username and password, a "Login" button, and a link to create a new account. The page uses some custom CSS for styling and includes external libraries for additional styling.

register.html: This HTML code is for a simple registration page. It includes fields for a username and password, a "Register" button, and a link to log in. The page uses Bootstrap and Font Awesome for styling and includes custom CSS for additional styling.

receipt.html: This HTML template extends a base template, and it creates a form for users to add receipts with item details. It also displays a list of existing receipts in a table, allowing users to delete or update them. The page includes styling with Bootstrap and custom CSS for aesthetics and layout. Additionally, there are options to generate a bill and log out.

update_receipt.html: This HTML template is for updating data in a web application. It includes a form for editing details related to an item, with fields pre-filled using existing data. The page uses Bootstrap for styling and some custom CSS. Users can update the data by clicking the "Update Data" button.

pdf.html: This HTML template creates a receipt for a purchase with the following features:

  • It includes Bootstrap for styling and custom CSS.
  • Displays company details, item information, and a total sum.
  • Provides a "Generate Receipt" button that triggers the print functionality when clicked.
  • JavaScript is used to extract the receipt content and initiate printing.

The page offers a printable receipt for users to save or use for their records.

base.html: In this html file we write the code of the table and some basic margin padding which we apply in some html files for that we joint some html file with base.html file

urls.py : below are the urls.py file those connect html file with views.py file



admin.py:Here we are registering our models.

Deployement of the Project

Run these commands to apply the migrations:

python3 manage.py makemigrations
python3 manage.py migrate

Run the server with the help of following command:

python3 manage.py runserver

Output


👁 Image

👁 Image


👁 Image


👁 update-base
base.html


👁 Image




Comment
Article Tags: