Hello! I have books model with url and I want to hide url before someone will purchase for it, my models.py:
class Book(models.Model):
name = models.TextField()
description = models.TextField()
book = models.FileField(upload_to='books/')
class BookImage(models.Model):
book = models.ForeignKey(Book, on_delete=models.CASCADE)
name = models.ImageField(upload_to='images/')
html template:
{% extends "base.html" %}
{% block content %}
<ol>
{% for book in books %}
<li class="post">
<div>
<b>Name: {{ book.name }}</b>
</div>
<div>
<b>Description: {{ book.description }}</b>
</div>
<div>
<a href="{{ book.book.url }}" target="_blank" rel="noopener noreferrer">{{ book.book }}</a> // I want to hide this url before purchase
</div>
<hr>
{% for image in book.bookimage_set.all %}
<div id="carouselExample" class="carousel slide">
<div class="carousel-inner">
{% for image in book.bookimage_set.all %}
<div class="carousel-item {% if forloop.first %}active{% endif %}">
<img src="{{ image.name.url }}" class="d-block w-100" alt="{{ image.name }}">
</div>
{% endfor %}
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
{% endfor %}
</li>
<hr>
{% endfor %}
</ol>
{% endblock %}