skip to Main Content

I have a django project which i’m using to create an inventory management system. I have a html website which shows the product description. It should also show the barcode image which is generated by the code. You can see the barcode image being generated by the program but you cannot view it in the webpage unless you open in manually by going to the file where the image is being saved.

<!-- inventory/product_detail.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ product.name }}</title>
</head>
<body>
    <h1>{{ product.name }}</h1>
    <p>Barcode:</p>
    <img src="{{ product.barcode_image.url|default:'#' }}" alt="Barcode Image">
    <!-- Use product.barcode_image.url to get the URL of the barcode image -->
    <p>Barcode Image URL: {{ product.barcode_image.url }}</p>
    <p>Quantity: {{ product.quantity }}</p>
    <p>Price: ${{ product.price }}</p>
    <a href="{% url 'product_list' %}">Back to Product List</a>
</body>
</html>

This is the product_detail page. I would like the page to show me the barcode image being generated by my django code.

2

Answers


  1. Chosen as BEST ANSWER

    This was fixed by changing the generate_unique_barcode porgram to save the files in a particular format and then also needed to change the url to make sure it was searching for the right file in the given folder


  2. Save the Image in the "same file" where you have "stored your HTML File" and write the name of the image with an extension in img scr. This might help you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search